Codeigniter 3 send email without smtp

耗尽温柔 提交于 2019-12-01 10:59:52

Perfect solution is as below:

Step 1:

Download PhpMailer for CodeIgniter from below link.

https://github.com/ivantcholakov/codeigniter-phpmailer

Step 2:

Extract. Put third_party, libraries, helpers and config folder into your CI application folder.

There will just index file(s) in each folder that will ask you to replace. Click replace and continue.

Step 3:

Open application/config/email.php

And do some updates according to your email account. I am using gmail, so I am giving gmail settings as below.

$config['protocol']         = 'smtp'; // 'mail', 'sendmail', or 'smtp'
$config['mailpath']         = '/usr/sbin/sendmail';
$config['smtp_host']        = 'smtp.gmail.com'; // if you are using gmail
$config['smtp_user']        = 'youremail@gmail.com';
$config['smtp_pass']        = 'sdkfjsk089sdfskKJ'; // App specific password
$config['smtp_port']        = 465; // for gmail
$config['smtp_timeout']     = 5;  

Step 4:

Now, in your controller where you want to send email. Use below code and its all done.

$this->load->library('email');
$this->email->from('youremail@gmail.com')
     ->reply_to('youremail@gmail.com')
     ->to(someone@somedomain.com)
     ->subject("Subject")
     ->message("Your Message")
     ->set_mailtype('html')
     ->send();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!