[英]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: 我找到了一个很棒的方法来为我解决:
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.