我们有一个PHP脚本来发送电子邮件,使用codeigniter构建。
每次都会正确发送许多电子邮件,但也有一些错误(在220和221代码之后)。
奇怪的部分是在日志中有250个statussus和250 recipient ok
我收到错误后:<br />Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.<br /><pre>User-Agent: CodeIgniter
我无法在邮件服务器的日志中找到奇怪的东西。
完整错误:
ERROR 220 {SERVER} Ready <br /><pre>hello: {server} Hello {Bussiness}
250 SIZE
</pre><pre>from: 250 sender ok <noreply@mymail.com>
</pre><pre>to: </pre>The following SMTP error was encountered: <br /><pre>quit: 250 recipient ok <myname@hotmail.com> </pre>The following SMTP error was encountered: 250 recipient ok <mynamek@hotmail.com> <br />Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.<br /><pre>User-Agent: CodeIgniter
所以我无法弄清楚它是邮件服务器问题还是php脚本问题。在SO上阅读一些相同的问题,但在PHP中总是一个简单的配置错误,尝试了一些,但它也不起作用。
PHP脚本:
<?php
error_reporting(0);
class Mailtest extends CI_Controller {
function __construct()
{
parent::__construct();
}
function index()
{
$this->load->library('email');
$config = array();
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['wordwrap'] = FALSE;
$config['protocol'] = "smtp";
$config['smtp_host'] = "server ip";
$config['smtp_port'] = "port";
$this->email->initialize($config);
$subject = 'SMTP test';
$htmlbody = "lorem ipsum";
$textbody = strip_tags($htmlbody);
$this->email->from('noreply@myemail.nl', 'my name');
$this->email->reply_to('noreply@myemail.nl', 'noreply');
$this->email->to('name@myemail.nl', 'my name');
$this->email->subject($subject);
$this->email->message($htmlbody);
$this->email->set_alt_message($textbody);
if(!$this->email->send())
{
$fout = $this->email->print_debugger();
var_dump($fout);
}
$this->email->clear();
}
}
我错过了什么?
PS:
code 250 = Requested mail action okay, completed
code 220 = <domain> Service ready
code 221 = <domain> Service closing transmission channel