Welcome Guest, Not a member yet? Register   Sign In
Email Library Problem with ini_get('safe_mode')
#1

[eluser]prezet[/eluser]
Hi

I've got a small form mailer application that makes use of the Email library. Been having problems getting it to work all night. The confusing thing was the normal PHP mail function works fine. Yet the CI library has issues sending the mail.

Anyway, I've narrowed down the problem to the following in the constructor and the initalize method:

Code:
$this->_safe_mode = ((boolean)@ini_get("safe_mode") === FALSE) ? FALSE : TRUE;

It seems that the safe_mode keeps getting set to false, and in turn fails to send the email.

I further narrowed down the problem to the fact that ini_get("safe_mode") is not returning any value. This seems true of my local dev environment, and my remote one on a different server.

Any ideas how I can fix this? I've checked my local php.ini file and safe_mode is off.

In fact, the only difference I can see which breaks the mail sending is the 5th parameter sent to sendmail if safe_mode is false:

Code:
function _send_with_mail()
    {    
        if ($this->_safe_mode == TRUE)
        {
            if ( ! mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str))
            {
                return FALSE;
            }
            else
            {
                return TRUE;
            }
        }
        else
        {
            // most documentation of sendmail using the "-f" flag lacks a space after it, however
            // we've encountered servers that seem to require it to be in place.
            if ( ! mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str, "-f ".$this->clean_email($this->_headers['From'])))
            {
                return FALSE;
            }
            else
            {
                return TRUE;
            }
        }
    }

If I remove this, it works fine. So why should that break it?

**confused**
#2

[eluser]TheFuzzy0ne[/eluser]
Are you able to connect to any other server, any other way?

For example:
Code:
echo file_get_contents('http://google.com');
#3

[eluser]prezet[/eluser]
Yep that's all fine.
#4

[eluser]TheFuzzy0ne[/eluser]
The only thing that comes into my mind is that some of the characters you're encoding into the Email may be breaking it. Other than that, I'm all out of ideas for now.




Theme © iAndrew 2016 - Forum software by © MyBB