【发布时间】:2017-02-06 11:45:28
【问题描述】:
PHPmailer 在我的本地主机上工作得很好,但是当我将它移到生产环境时,我收到了这种错误:
连接:打开 smtp.gmail.com:587, timeout=300, options=array ( ) 2016-09-28 12:58:01 连接:连接服务器失败。错误 2号“错误提示:stream_socket_client():无法连接到 smtp.gmail.com:587(连接超时)2016-09-28 12:58:01 SMTP 错误:无法连接到服务器:连接超时 (110) 2016-09-28 12:58:01 SMTP 连接()失败。
我已经尝试过 TLS 和 SSL,并相应地更新了端口。 我还运行了一个快速的 nmap 扫描,它显示端口已正确打开,所以这不是问题
PORT STATE SERVICE
25/tcp filtered smtp
443/tcp open https
465/tcp open smtps
587/tcp open submission
这是来自我的应用程序的 sn-p:
public function __construct() {
parent::__construct();
$this->isSMTP();
$this->SMTPAuth = true;
$this->SMTPSecure = 'tls';
$this->Host = MAIL_HOST;
$this->Username = MAIL_USERNAME;
$this->Password = MAIL_PASSWORD;
$this->From = 'myemail';
$this->FromName = 'Name';
$this->addEmbeddedImage('../public/img/message_logo.png', 'logo');
$this->isHTML(true);
$this->Port = 587;
$this->Subject = "SUBJECT";
$this->SMTPDebug = MAIL_SMTP_DEBUG;
}
有人知道接下来要检查什么吗?
【问题讨论】:
-
是的,正如我所说,它可以毫无问题地从我的本地主机发送邮件