Codeigniter 3 send email without smtp

对着背影说爱祢 提交于 2019-12-01 08:44:00

问题


I am not receiving an email, though everything seems fine. May be hosting issue? Any suggestion will be appreciated. Here is my code

    $this->load->library('email');
    $this->email->from('info@domain.com', 'Name');
    $this->email->to($seller_email);
    $this->email->subject('This is subject');
    $this->email->message('This is message!');
    $this->email->send();
    echo $this->email->print_debugger();

print_debugger function returns empty. Let me know you guys comments.


回答1:


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();


来源:https://stackoverflow.com/questions/34469344/codeigniter-3-send-email-without-smtp

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