【发布时间】:2016-09-05 10:18:39
【问题描述】:
我遇到了一个奇怪的问题。从昨天(左右)开始,php 邮件程序拒绝连接到 smtp 服务器。这以前工作得很好。我检查了密码或其他任何内容是否已更改,但应该都是正确的,但我收到了这些错误:
2016-09-05 10:06:43 SMTP ERROR: Failed to connect to server: Connection timed out (110) 2016-09-05 10:06:43 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Mailer Fehler: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Warning: Error while sending STMT_CLOSE packet. PID=25524 in Unknown on line 0
设置代码为:
$mail->IsSMTP();
//$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->Host = "smtp.office365.com";
$mail->Port = 587;
$mail->SMTPSecure = "tls";
$mail->Username = "theCorrectUsername";
$mail->Password = "theCorrectPassword";
知道可能是什么原因吗?
小更新:
似乎phpmailer无法连接到任何smtp服务器...这可能是php文件所在服务器的防火墙问题吗?
另一个更新:
->SMTPDebug = 2;给我:
2016-09-05 17:11:31 Connection: opening to smtp.office365.com:587, timeout=30, options=array ( ) 2016-09-05 17:12:01 Connection: Failed to connect to server. Error number 2. "Error notice: stream_socket_client(): unable to connect to smtp.office365.com:587 (Connection timed out) 2016-09-05 17:12:01 SMTP ERROR: Failed to connect to server: Connection timed out (110)
【问题讨论】:
-
检查端口号,这个谷歌搜索
office365.com smtp port number提示587不正确,也许他们改变了什么 -
我检查过了,应该是正确的 smtp 端口
-
阅读错误消息中链接的故障排除指南。做测试看看是否是DNS,防火墙阻止等。
-
我进行了故障排除并尝试了另一个 smtp 服务器...得到了相同的结果。这似乎与 php 代码有关
-
->SMTPDebug=2告诉你什么?