SMTP-& gt;错误:无法连接到服务器:连接超时(110)以下发件人地址失败:xxxxx@gmail.com错误 [英] SMTP -> ERROR: Failed to connect to server: Connection timed out (110) The following From address failed: xxxxx@gmail.com ERROR

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

问题描述

在联系表中,它在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: xxxxx@gmail.com 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   = "xxxx@gmail.com"; 
    $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("xxx@gmail.com","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-&amp; gt;错误:无法连接到服务器:连接超时(110)以下发件人地址失败:xxxxx@gmail.com错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆