首页 文章

Php SMTP错误10060:无法连接到服务器

提问于
浏览
0

我有PHP代码使用SMTP连接发送电子邮件;它在两周前完美运作 . 但突然停止工作 . 不知道是什么问题 .

SMTP - >错误:未能连接到服务器:连接尝试失败,因为连接方在一段时间后没有得到正确的回应,或者由于连接主机未能响应而未 Build 连接失败 . (10060)SMTP错误:可能无法连接到SMTP主机 .

//start  mailing function
require_once('PHPMailer_v5.1\class.phpmailer.php');
$mail  = new PHPMailer();   
$mail->IsSMTP();
//MAIL config
$mail->SMTPAuth   = true;
$mail->SMTPDebug  = 1;
$mail->Host       = "localhost";      // set as the SMTP server
$mail->Port       = 25;
$mail->Username   = "myemail@web.com";  // localhost email username
$mail->Password   = "XXXX";            
//End mail config
$mail->From       = $sender_email;
$mail->FromName   = $sender_user_name;
$mail->Subject    = $subject;
$mail->MsgHTML($body);
$mail->AddAddress($to,$to_name);
$mail->IsHTML(true); // send as HTML
if(!$mail->Send()) {//to see if we return a message or a value bolean
    echo "<p>Confirmation Mail delivery failed due to invalid email specified !</p>";
}

1 回答

  • 0

    这是由于

    $mail->Host       = "localhost";      // set as the SMTP server
    

    我改成了

    $mail->Host       = "mail.web.com";      // set as the SMTP server
    

    它现在有效!

相关问题