Can't send mails with mail() function - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Can't send mails with mail() function (/showthread.php?tid=61565) |
Can't send mails with mail() function - V I R U S - 04-26-2015 Hello! I was just trying to send my mails with CI3 with default mail() function, but getting an error (German) Die E-Mail konnte mit PHP mail() nicht gesendet werden. Ihr Server ist offenbar nicht konfiguriert, um mit dieser Methode E-Mails zu versenden. (Translated) The email could not be sent with with PHP mail(). Your server is apparently not configured to send e-mails using this method. Strange thing, that if i use pure mail() function without CI3, it works! I was following down the error and found in Email library. The function PHP Code: protected function _send_with_mail() As you can see, there is a check if PHP is running in safe mode, if no, use this: PHP Code: return mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str, '-f '.$this->clean_email($this->_headers['Return-Path'])); My server is running with Debian 7.8 and latest php-fpm and sendmail. Is there some solution not to touch the core library? RE: Can't send mails with mail() function - Avenirer - 04-27-2015 In pure php did you try to send an email using a fifth parameter and it worked? http://php.net/manual/en/function.mail.php RE: Can't send mails with mail() function - V I R U S - 04-27-2015 So, was trying right now. Fifth parameter is not being accepted at all by PHP 6.8 and latest sendmail from apt-get. Some reconfiguration of them required? RE: Can't send mails with mail() function - V I R U S - 04-27-2015 So, okay. I found the problem. For anyone wh might have the same trouble, here is solution. My server's php was configured to send mails already with the "-f" flag in php.ini. So it was: sendmail_path = /usr/sbin/sendmail -t -i -f [email protected] Just remove -f [email protected] so it will look like "sendmail_path = /usr/sbin/sendmail -t -i" and enjoy! |