codeigniter:通过localhost发送电子邮件

时间:2017-11-13 10:44:24

标签: php codeigniter email

我已经配置了php.ini,sendmail.ini并且还为gmail使用了正确的端口和配置,我还在gmail上启用了不太安全的应用程序,但是当我检查收件箱并且没有显示错误时我可以看到邮件

这是控制器

                   $config['protocol'] = 'smtp';
                    $config['smtp_host'] = 'ssl://smtp.googlemail.com';
// SMTP Port - the port that you is required
$config['smtp_port'] = 465;
$config['smtp_user'] = $sender_email;
$config['smtp_pass'] = $sender_password;
$this->load->library('email', $config);
$this->email->from($sender_email);
$this->email->to($to_email);
$this->email->subject($subject);
$this->email->message($message);
                    if(!$this->email->send()) {
                        show_error($this->email->print_debugger());
                    }
                    else{
                        echo 'Your email has been sent!<br/>';
                    }

                echo $message2; //send this in email

的php.ini

extension=php_openssl.dll

sendmail.ini

smtp_server=smtp.gmail.com
smtp_port=465
auth_username= xxxx.gmail.com
auth_password= xxxx

1 个答案:

答案 0 :(得分:0)

您可以使用以下工具测试localhost上的电子邮件。设置相当简单,并在说明中清楚地解释。 Test Mail Server Tool