我需要帮助,请 这是我的代码:的PHPMailer和Gmail SMTP错误:无法连接到服务器:网络不可达(101)SMTP连接()失败
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPDebug = 2;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Port = 587;
$mail->Username = '[email protected]';
$mail->Password = 'somepass';
$mail->addAddress('[email protected]', 'Josh Adams');
$mail->Subject = 'PHPMailer GMail SMTP test';
$body = 'This is the HTML message body in bold!';
$mail->MsgHTML($body);
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
,我得到这个错误: 2013-12-11 15:15:02 SMTP错误:无法连接到服务器:网络无法访问(101)SMTP连接()失败。邮件程序错误:SMTP连接()失败。
请帮忙吗?