我整个早上都在尝试谷歌,我想我现在需要 Stackoverflow!
我写了一个简单的脚本来发送邮件(从 hotmail 到 gmail),但我收到了这个错误:
SMTP -> ERROR: Failed to connect to server: 连接尝试失败,因为连接方在一段时间后没有正确响应,或者连接失败,因为连接的主机没有响应。(10060)SMTP Connect() 失败。错误
这是代码:
<?php
require_once("../includes/phpMailer/class.phpMailer.php");
require_once("../includes/phpMailer/class.smtp.php");
$to_name = "RECEIVER NAME";
$to = "RECEIVER@gmail.com";
$subject = "Mail test at " . strftime("%T", time());
$message = "This is a test message";
$message = wordwrap($message, 70);
$from_name = "MY NAME";
$from = "MY_EMAIL@hotmail.it";
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 2;
$mail->Host = "smtp.live.com";
$mail->Port = 25;
$mail->SMTPAuth = true;
$mail->Username = "MY USERNAME (hotmail)";
$mail->Password = "MY PASSWORD (hotmail)";
$mail->FromName = $from_name;
$mail->From = $from;
$mail->AddAddress($to, $to_name);
$mail->Subject = $subject;
$mail->Body = $message;
$result = $mail->Send();
echo $result ? 'Sent' : 'Error';
?>
另一个信息是,甚至标准的 mail() 函数都不起作用,检查 php 信息我发现了这个:
sendmail_from - 我的正确邮件(hotmail)
sendmail_path - 没有价值
SMTP - 本地主机
smtp_port - 25
谢谢!!