SMTP成功但电子邮件未送达

时间:2015-11-21 18:23:44

标签: php codeigniter

我是CodeIgntier的新手。我正在尝试在CodeIgniter上设置SMTP。我在页面上收到成功消息,但未发送电子邮件。有人可以帮帮我吗?

 $config = Array(
                        'protocol' => 'smtp',
                        'smtp_host' => 'ssl://smtp.gmail.com',
                        'smtp_port' => 465,
                        'smtp_user' => 'xxx@gmail.com',
                        'smtp_pass' => 'xxx',
                        'mailtype'  => 'html', 
                        'charset'   => 'iso-8859-1'
                    );
                    $this->load->library('email', $config);
                    $this->email->from('xxx@gmail.com', 'Admin Team');
                    $sendTo = $this->input->post('email');
                    $message= 'Hello';


                    $this->email->to($sendTo);
                    $this->email->subject('Verification Email');
                    $this->email->message($message);
                    if($this->email->send()){
                        echo "Success";
                    }

2 个答案:

答案 0 :(得分:0)

您提到了np.std(ddof=...)。在谷歌有安全保护电话2-Step Verification。确保它在那里,如果删除它并尝试

您的代码没有错误。 。要删除它,请检查this link

答案 1 :(得分:0)

您的代码似乎没问题,请确保您的服务器已启动并运行openssl扩展,并检查防火墙是否使用了smtp端口(在您的情况下为465)。我还建议您使用来自https://github.com/ivantcholakov/codeigniter-phpmailer whic的第三方库phpmailer(主要用于在您的消息和链接中发送html)

喝彩!

相关问题