某个服务器的PHPMailer超时

某个服务器的PHPMailer超时,php,phpmailer,Php,Phpmailer,从昨天开始,我一直在拼命尝试用PHPMailer(最新版本)运行一个非常简单的电子邮件脚本 最荒谬的是,同一个脚本在两台服务器上不起作用,但在另一台服务器上却起作用 这是我的尝试(来自PHPMailer示例): 输出调试: 2017-06-08 08:43:55 Connection: opening to smtp.live.com:587, timeout=300, options=array () 2017-06-08 08:44:58 Connection failed. Error

从昨天开始,我一直在拼命尝试用PHPMailer(最新版本)运行一个非常简单的电子邮件脚本

最荒谬的是,同一个脚本在两台服务器上不起作用,但在另一台服务器上却起作用

这是我的尝试(来自PHPMailer示例):

输出调试:

2017-06-08 08:43:55 Connection: opening to smtp.live.com:587, timeout=300, options=array ()

2017-06-08 08:44:58 Connection failed. Error #2: stream_socket_client(): unable to connect to smtp.live.com:587 (Connection timed out) [/home/public_html/work/PHPMailer/class.smtp.php line 292]

2017-06-08 08:44:58 SMTP ERROR: Failed to connect to server: Connection timed out (110)

SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
我认为这取决于服务器的配置。我必须查看哪个参数


提前感谢

无需使用:
$mail->isSMTP()

评论这个<代码>$mail->isSMTP()


无需使用:
$mail->isSMTP()

评论这个<代码>$mail->isSMTP()


$mail->Timeout=60;//设置超时(秒)添加此项并尝试在无法工作的服务器中是否有防火墙或使用端口587进行SMTP通信的限制?@RïshïKïshKümar没有更改FedericoJoséSorenson老实说,我没有know@Andrea ,.. 请评论这行$邮件->isSMTP();如果没有这一行,它就可以工作……但是这将使用标准的php mail()?$mail->Timeout=60;//设置超时(秒)添加此项并尝试在无法工作的服务器中是否有防火墙或使用端口587进行SMTP通信的限制?@RïshïKïshKümar没有更改FedericoJoséSorenson老实说,我没有know@Andrea ,.. 请评论这行$邮件->isSMTP();如果没有这行代码,它就可以工作…但是这使用标准的php mail()?关闭防火墙,然后再试一次;它可以工作…但是这使用标准的php邮件()?$mail->isSMTP()。。它将邮件程序设置为使用SMTP。。但是它不是必需的,我会关掉你的防火墙,然后再试一次;它可以工作…但是这使用标准的php邮件()?$mail->isSMTP()。。它将邮件程序设置为使用SMTP。。但我不认为这是必要的
2017-06-08 08:43:55 Connection: opening to smtp.live.com:587, timeout=300, options=array ()

2017-06-08 08:44:58 Connection failed. Error #2: stream_socket_client(): unable to connect to smtp.live.com:587 (Connection timed out) [/home/public_html/work/PHPMailer/class.smtp.php line 292]

2017-06-08 08:44:58 SMTP ERROR: Failed to connect to server: Connection timed out (110)

SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
<?php

//error_reporting(E_ALL);
error_reporting(E_STRICT);
date_default_timezone_set('America/Toronto');

require '../PHPMailerAutoload.php';
require_once('../class.phpmailer.php');

$mail = new PHPMailer;
//$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Host = "smtp.live.com";
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->Username = "xxxx@xxxx.com";
$mail->Password = "xxxxx";
$mail->setFrom('from@example.com', 'First Last');
$mail->addReplyTo('replyto@example.com', 'First Last');
$mail->addAddress('whoto@example.com', 'John Doe');
$mail->Subject = 'PHPMailer SMTP test';
$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; 

$body = file_get_contents('test.html');
$body = eregi_replace("[\]",'',$body);
$mail->MsgHTML($body);

//send the message, check for errors
if (!$mail->send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
}

?>
$mail->Timeout =   60; // set the timeout (seconds)
$mail->SMTPKeepAlive = true; // don't close the connection between messages