无法连接到服务器

无法连接到服务器

本文介绍了SMTP->错误:无法连接到服务器:连接超时(110)以下发件人地址失败:[email protected]错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在联系表中,它可以在localhost正常工作。托管后无法正常工作。显示错误

In contact form it's working fine in localhost. While hosted it's not working. Showing the error

**"SMTP -> ERROR: Failed to connect to server: Connection timed out (110) The following From address failed: [email protected] ERROR"**

我附上了contact_submit.php代码

I attached my contact_submit.php code form

    include_once('class.phpmailer.php');

   $mail->IsSMTP(); //
    $mail->Host       = "smtp.gmail.com";
    $mail->SMTPDebug  = 1;
    $mail->SMTPAuth   = true;
    $mail->Host       = "smtp.gmail.com";
    $mail->Port       = 587;
    $mail->Username   = "[email protected]";
    $mail->Password   = "xxxx@123";
    $mail->SMTPSecure = "tls";
    $mail->SetFrom($email, $name);

    $mail->AddReplyTo($email,$name);

    $mail->Subject    = "Contact - xxx";

    $mail->AltBody    = "To view the message, please use an HTML compatible email viewer!";

    $mail->MsgHTML($body);
    $mail->AddAddress("[email protected]","xxx");


    if(!$mail->Send())
    {
        echo $mail;
      echo "Mailer Error: " . $mail->ErrorInfo;
    }
    else
        {
      echo '<META HTTP-EQUIV="Refresh" Content="0; URL=contact.php?id='.$id.'&send=success">';
      exit;
    }

我正在使用phpmailer 5.2.1。

I'm using phpmailer 5.2.1.

我联系了托管方,但没有得到实际答复。

I contacted the hosting side, but i'm not getting actual response.

推荐答案

我相信您必须在端口465(而不是端口587)上连接到smtp.gmail.com。此外,还需要SSL。因此,您应该具有:

I believe you have to connect to smtp.gmail.com on port 465, not port 587. Also, SSL is required. So, you should have:

$mail->Host       = "smtp.gmail.com";
$mail->Port       = 465;
$mail->SMTPSecure = "ssl";

这篇关于SMTP->错误:无法连接到服务器:连接超时(110)以下发件人地址失败:[email protected]错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 07:45