phpMailer smtp已停止工作

phpMailer smtp已停止工作,php,phpmailer,Php,Phpmailer,我遇到了一个奇怪的问题。从昨天(大约)起,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/PHP

我遇到了一个奇怪的问题。从昨天(大约)起,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) 

我想你的端口号不正确。使用此演示代码:

  <?php

//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have access to that
#require '../PHPMailerAutoload.php';
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 0;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = 'mail.domain.com';
// if your network does not support SMTP over IPv6
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = 25;
//Set the encryption system to use - ssl (deprecated) or tls
//$mail->SMTPSecure = 'tls';
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = "demo@domain.com";
//Password to use for SMTP authentication
$mail->Password = "password";
//Set who the message is to be sent from
$mail->setFrom('demo@domain.com', 'subillion');
//Set an alternative reply-to address
#$mail->addReplyTo('replyto@example.com', 'Demo');
//Set who the message is to be sent to
$mail->addAddress("example@gmail.com");

//Set the subject line
$mail->Subject = 'Demo !!';
//Read an HTML message body from an external file, convert referenced images to embedded,
$mail->isHTML(true);

$msgbody = "This is a demo test !";
$mail->Body = $msgbody;
//send the message, check for errors
if (!$mail->send()) {
// echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
}

?>

检查端口号,此Google搜索
office365.com smtp端口号
表明
587
不正确,可能他们更改了某些内容我检查了它,应该是SMT的正确端口请阅读错误消息链接的疑难解答指南。做测试,看看它是否是DNS,防火墙块等。我经历了故障排除,并尝试了另一个smtp服务器…得到了相同的结果。这似乎与php代码有关
->SMTPDebug=2
告诉您了什么?谢谢,但我遇到了另一个连接错误:连接:无法连接到服务器。错误号2。“错误通知:stream_socket_client():无法连接到smtp.office365.com:25(连接超时)直到昨天,端口587工作正常,但现在连接需要花费很长时间,然后抛出超时错误。”