简体   繁体   English

SMTP->错误:无法连接到服务器:连接超时(110)以下“发件人”地址失败:xxxxx@gmail.com错误

[英]SMTP -> ERROR: Failed to connect to server: Connection timed out (110) The following From address failed: xxxxx@gmail.com ERROR

In contact form it's working fine in localhost. 在联系表中,它在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"** 

I attached my contact_submit.php code form 我附上了contact_submit.php代码表

    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; 
    }

I'm using phpmailer 5.2.1. 我正在使用phpmailer 5.2.1。

I contacted the hosting side, but i'm not getting actual response. 我联系了托管方,但没有得到实际答复。

I believe you have to connect to smtp.gmail.com on port 465, not port 587. Also, SSL is required. 我相信您必须在端口465而不是端口587上连接到smtp.gmail.com。此外,还需要SSL。 So, you should have: 因此,您应该具有:

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

I had a similar problem, with mail being sent correctly from my local server but not my live one on the internet. 我遇到了类似的问题,邮件是从本地服务器正确发送的,而不是从Internet发送的实时邮件。 It turned out my host (Bluehost) blocked outgoing connections on port 465. 原来,我的主机(Bluehost)阻止了端口465上的传出连接。

I found a wonderful how-to which fixed it for me: 我找到了一个很棒的方法来为我解决:

  1. In your cPanel > Mail, find the MX (MX Entry) section, and select 'remote mail exchanger'. 在cPanel>邮件中,找到MX(MX条目)部分,然后选择“远程邮件交换器”。
  2. In the cPanel email accounts section, create the appropriate email address (don't skip this) 在cPanel电子邮件帐户部分中,创建适当的电子邮件地址(请勿跳过此操作)
  3. Don't use "smtp.live.com" as your smtp host. 不要将“ smtp.live.com”用作您的smtp主机。 Use the smtp host of your Shared Linux Hosting smtp. 使用共享Linux主机smtp的smtp主机。 I don't know how you will get yours. 我不知道你怎么得到你的。 Mine is boxXXXX.bluehost.com. 我的是boxXXXX.bluehost.com。
  4. Set your username and password to be the same as the email account you just set-up in cPanel. 将您的用户名和密码设置为与您刚刚在cPanel中设置的电子邮件帐户相同。

You can increase the time out by prepending your code with: 您可以通过在代码前添加以下代码来增加超时时间:

set_time_limit(3600);

and then specifying the Timeout of the $mail object as such: 然后指定$mail对象的超时,如下所示:

$mail->Timeout = 3600;       

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SMTP-&gt;错误:无法连接到服务器:连接超时(110) - SMTP -> ERROR: Failed to connect to server: Connection timed out (110) PHPMailer SMTP无法连接到服务器:连接超时(110)到Gmail - PHPMailer SMTP Failed to connect to server: Connection timed out (110) to Gmail SMTP-&gt;错误:无法连接到服务器:连接超时(110)SMTP错误:无法连接到SMTP主机。 - SMTP -> ERROR: Failed to connect to server: Connection timed out (110) SMTP Error: Could not connect to SMTP host. PHPMailer的臭名昭著的SMTP错误:无法连接到服务器:连接超时(110)SMTP connect()失败 - PHPMailer's infamous SMTP ERROR: Failed to connect to server: Connection timed out (110) SMTP connect() failed 无法连接到服务器:连接超时(110)SMTP Connect()失败。 邮件未发送。邮件错误:SMTP Connect()失败 - Failed to connect to server: Connection timed out (110)SMTP Connect() failed. Message was not sent.Mailer error: SMTP Connect() failed SMTP错误:无法连接到服务器:使用PHPMailer和Outlook SMTP连接超时(110) - SMTP ERROR: Failed to connect to server: Connection timed out (110) with PHPMailer and Outlook SMTP SMTP 错误:无法连接到服务器:使用 phpmailer 时连接超时(110) - SMTP ERROR: Failed to connect to server: Connection timed out (110) when using phpmailer 如何解决:PHP中无法通过主机smtp.gmail.com建立连接[连接超时#110]错误 - How to resolve: Connection could not be established with host smtp.gmail.com [Connection timed out #110] error in PHP SMTP - &gt;错误:无法连接到服务器:以下发件人地址失败::调用邮件()未连接邮件程序错误 - SMTP -> ERROR: Failed to connect to server: The following From address failed: : Called Mail() without being connected Mailer Error Gmail帐户SMTP-&gt;错误:无法连接到服务器:连接被拒绝(111) - Gmail Account SMTP -> ERROR: Failed to connect to server: Connection refused (111)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM