Unable to send email using SMTP gmail config in codeigniter 3

别等时光非礼了梦想. 提交于 2019-12-05 15:58:58

Are you try this?

$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'xxx',
'smtp_pass' => 'xxx',
'mailtype'  => 'html', 
'charset'   => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");

// Set to, from, message, etc.

$result = $this->email->send();

And make sure you had setting your email account with Allowing less secure apps to access your account

Quỳnh Nguyễn's answer worked for me too. However I think it's worth pointing out that my code fails unless I put the line

$this->email->set_newline("\r\n");

Without that line, gmail complaints about wrong user/password :|

Regards

Al Herrera

I had difficulties making this native CI feature to work. I had to implement an external library: PHPMailer. Check this thread.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!