CodeIgniter unable to send email using PHP mail() CodeIgniter unable to send email using PHP mail() codeigniter codeigniter

CodeIgniter unable to send email using PHP mail()


Had similar issue.

That's working code from the controller :

        $config = array();        $config['useragent']           = "CodeIgniter";        $config['mailpath']            = "/usr/bin/sendmail"; // or "/usr/sbin/sendmail"        $config['protocol']            = "smtp";        $config['smtp_host']           = "localhost";        $config['smtp_port']           = "25";        $config['mailtype'] = 'html';        $config['charset']  = 'utf-8';        $config['newline']  = "\r\n";        $config['wordwrap'] = TRUE;        $this->load->library('email');        $this->email->initialize($config);        $this->email->from($fromEmail, $fromName);        $this->email->to($email);        $this->email->subject('Тест Email');        $this->email->message($this->load->view('email/'.$type.'-html', $data, TRUE));        $this->email->send();


Clearly, there does not seem to be a definitive 'one size fits all' answer. What worked for me was changing

$config['protocol'] = 'smtp';

TO:

$config['protocol'] = 'mail';

Hope this helps...


Do you have an email.php file in your config folder? Maybe there's a problem with your configuration in there.