CodeIgniter unable to send email using PHP mail()

Viewed 80965

I'm trying to send an e-mail with Codeigniter like this:

$this->load->library('email');

$this->email->from("myemail@email.com");
$this->email->reply_to("myemail@email.com");
$this->email->to("myemail@email.com");
$this->email->subject("Test mail");
$this->email->message("Email body");
$this->email->set_alt_message("Email body txt");
$this->email->send();

and I got this on the email debugger: Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.

If I do e simple PHP mail() function with the same addresses, it works but when I use CodeIgniter it gives me the error. So why would it work with simple mail() but not with CodeIgniter ? Any ideas ?

Thanks.

12 Answers

Ensure that Apache can send emails.

To check your current sendmail status: sestatus -b | grep httpd_can_sendmail

Change it to this if it is off: sudo setsebool -P httpd_can_sendmail on

Related