Mandrill:SMTP错误:无法连接到服务器:连接超时(110)
我有以下配置,可以在一小时内向50个客户发送大量电子邮件 SMTP提供程序:Mandrill 每小时限额:380封电子邮件/小时 邮箱声誉:良好,不滥发垃圾邮件 PHPMailer:版本5 问题:当我执行脚本时,有时它会向50位客户中的每一位发送邮件,而有时,它会停止发送邮件,说: SMTP错误:无法连接到服务器:连接超时110 它会自动恢复并向剩余的客户发送电子邮件 我的代码: 我可以很好地运行send脚本,然后一个接一个地连续运行2到3次。它工作正常,但突然无法连接 我问了这个问题作为评论。有人建议我在现场提出一个新问题 除了添加,我不知道在哪里修复 $phpMailer->SMTPKeepAlive=true;和$phpMailer->SmtpClose;前后for循环 不过,我不知道这是否正确的做法 您的建议,以解决上述问题将高度赞赏Mandrill:SMTP错误:无法连接到服务器:连接超时(110),smtp,phpmailer,mandrill,Smtp,Phpmailer,Mandrill,我有以下配置,可以在一小时内向50个客户发送大量电子邮件 SMTP提供程序:Mandrill 每小时限额:380封电子邮件/小时 邮箱声誉:良好,不滥发垃圾邮件 PHPMailer:版本5 问题:当我执行脚本时,有时它会向50位客户中的每一位发送邮件,而有时,它会停止发送邮件,说: SMTP错误:无法连接到服务器:连接超时110 它会自动恢复并向剩余的客户发送电子邮件 我的代码: 我可以很好地运行send脚本,然后一个接一个地连续运行2到3次。它工作正常,但突然无法连接 我问了这个问题作为评论。
谢谢这看起来确实像是一个mandrill问题-您在PHPMailer中做的一切都是正确的。他们可能正在使用循环DNS将连接分散到服务器池上,其中一个或多个服务器可能已关闭。如果他们的服务器工作不正常,那么在你这一方你真的无能为力。唯一真正的退路是使用本地邮件服务器,并将其设置为通过mandrill进行中继。这将负责排队和重试发送,还可以使你的应用程序能够处理其他事情,因为发送是异步的
您肯定应该使用SMTPKeepAlive—它将使发送更加高效,并减少发生此问题的可能性,因为它只使用一台服务器。根据您的本地环境,这也可能是因为您的主机提供商或ISP限制出站SMTP连接。有些具有速率限制,或者如果超过某些限制,将重定向连接。您也可能有smtp.mandrillapp.com的过时DNS记录,这将导致您的系统尝试在不再用于该主机名的IP地址上访问smtp.mandrillapp.com。您可以使用Wireshark之类的工具来实际跟踪您正在连接或试图连接的特定IP。PHPMailer可能还提供了更多详细的日志记录,但您希望了解更多有关您试图连接到何处以确定问题的详细信息
{
$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->SMTPDebug = 4;
$mail->Debugoutput = 'html';
$mail->Host = SMTP_HOST;
$mail->Port = 25;
$mail->SMTPAuth = true;
$mail->Username = SMTP_USERNAME;
$mail->Password = SMTP_PASSWORD;
$mail->setFrom(SMTP_USERNAME, SMTP_NAME);
For Loop{
$msgHTML = "<table width='500px;' align='center'>";
$msgHTML .= "<tr><td>Dear Customer</td></tr>";
$msgHTML .= "</table>";
$mail->addReplyTo();
$mail->addAddress();
$mail->Subject = 'Loan Request Follow Up from xyzdummy.com.';
$mail->msgHTML($msgHTML);
$mail->AltBody = 'This is a plain-text message body';
try{
$mail->send();
echo "Mail Sent to ->".$forloop[$j]['EmailId'] ;
}
catch (phpmailerException $e)
{
echo $e->errorMessage(); //Pretty error messages from PHPMailer
echo "Mail Failed to ->".$forloop[$j]['EmailId'] ;
}
$mail->clearAddresses();
$mail->clearCCs();
$mail->clearBCCs();
}
}
Connection: opening to smtp.mandrillapp.com:25, t=10, opt=array ()
Connection: opened
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "220 smtp.mandrillapp.com ESMTP"
SMTP -> get_lines(): $data is "220 smtp.mandrillapp.com ESMTP"
SERVER -> CLIENT: 220 smtp.mandrillapp.com ESMTP
CLIENT -> SERVER: EHLO smtp.mandrillapp.com
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "250-relay-2.ap-southeast-1.mandrill-relay-prod"
SMTP -> get_lines(): $data is "250-relay-2.ap-southeast-1.mandrill-relay-prod"
SMTP -> get_lines(): $data was "250-relay-2.ap-southeast-1.mandrill-relay-prod"
SMTP -> get_lines(): $str is "250-PIPELINING"
SMTP -> get_lines(): $data is "250-relay-2.ap-southeast-1.mandrill-relay-prod250-PIPELINING"
SMTP -> get_lines(): $data was "250-relay-2.ap-southeast-1.mandrill-relay-prod250-PIPELINING"
SMTP -> get_lines(): $str is "250-SIZE 26214400"
SMTP -> get_lines(): $data is "250-relay-2.ap-southeast-1.mandrill-relay-prod250-PIPELINING250-SIZE 26214400"
SMTP -> get_lines(): $data was "250-relay-2.ap-southeast-1.mandrill-relay-prod250-PIPELINING250-SIZE 26214400"
SMTP -> get_lines(): $str is "250-STARTTLS"
SMTP -> get_lines(): $data is "250-relay-2.ap-southeast-1.mandrill-relay-prod250-PIPELINING250-SIZE 26214400250-STARTTLS"
SMTP -> get_lines(): $data was "250-relay-2.ap-southeast-1.mandrill-relay-prod250-PIPELINING250-SIZE 26214400250-STARTTLS"
SMTP -> get_lines(): $str is "250-AUTH PLAIN LOGIN"
SMTP -> get_lines(): $data is "250-relay-2.ap-southeast-1.mandrill-relay-prod250-PIPELINING250-SIZE 26214400250-STARTTLS250-AUTH PLAIN LOGIN"
SMTP -> get_lines(): $data was "250-relay-2.ap-southeast-1.mandrill-relay-prod250-PIPELINING250-SIZE 26214400250-STARTTLS250-AUTH PLAIN LOGIN"
SMTP -> get_lines(): $str is "250-ENHANCEDSTATUSCODES"
SMTP -> get_lines(): $data is "250-relay-2.ap-southeast-1.mandrill-relay-prod250-PIPELINING250-SIZE 26214400250-STARTTLS250-AUTH PLAIN LOGIN250-ENHANCEDSTATUSCODES"
SMTP -> get_lines(): $data was "250-relay-2.ap-southeast-1.mandrill-relay-prod250-PIPELINING250-SIZE 26214400250-STARTTLS250-AUTH PLAIN LOGIN250-ENHANCEDSTATUSCODES"
SMTP -> get_lines(): $str is "250 8BITMIME"
SMTP -> get_lines(): $data is "250-relay-2.ap-southeast-1.mandrill-relay-prod250-PIPELINING250-SIZE 26214400250-STARTTLS250-AUTH PLAIN LOGIN250-ENHANCEDSTATUSCODES250 8BITMIME"
SERVER -> CLIENT: 250-relay-2.ap-southeast-1.mandrill-relay-prod250-PIPELINING250-SIZE 26214400250-STARTTLS250-AUTH PLAIN LOGIN250-ENHANCEDSTATUSCODES250 8BITMIME
CLIENT -> SERVER: AUTH LOGIN
SMTP -> get_lines(): $data was ""
bl abla
CLIENT -> SERVER:
CLIENT -> SERVER: .
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "250 2.0.0 Ok: queued as D1D682A0B20"
SMTP -> get_lines(): $data is "250 2.0.0 Ok: queued as D1D682A0B20"
SERVER -> CLIENT: 250 2.0.0 Ok: queued as D1D682A0B20
CLIENT -> SERVER: QUIT
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "221 2.0.0 Bye"
SMTP -> get_lines(): $data is "221 2.0.0 Bye"
SERVER -> CLIENT: 221 2.0.0 Bye
Connection: closed
Connection: opening to smtp.mandrillapp.com:25, t=10, opt=array ()
SMTP ERROR: Failed to connect to server: Connection timed out (110)
SMTP connect() failed.
SMTP connect() failed.
Connection: opening to smtp.mandrillapp.com:25, t=10, opt=array ()
SMTP ERROR: Failed to connect to server: Connection timed out (110)
SMTP connect() failed.
SMTP connect() failed.
Connection: opening to smtp.mandrillapp.com:25, t=10, opt=array ()
SMTP ERROR: Failed to connect to server: Connection timed out (110)
SMTP connect() failed.
SMTP connect() failed.
SMTP ERROR: Failed to connect to server: Connection timed out (110)
SMTP connect() failed.
SMTP connect() failed.
Connection: opening to smtp.mandrillapp.com:25, t=10, opt=array ()
Connection: opened
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "220 smtp.mandrillapp.com ESMTP"
SMTP -> get_lines(): $data is "220 smtp.mandrillapp.com ESMTP"
SERVER -> CLIENT: 220 smtp.mandrillapp.com ESMTP
CLIENT -> SERVER: EHLO smtp.mandrillapp.com
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "250-relay-2.ap-southeast-1.mandrill-relay-prod"
SMTP -> get_lines(): $data is "250-relay-2.ap-southeast-1.mandrill-relay-prod"
SMTP -> get_lines(): $data was "250-relay-2.ap-southeast-1.mandrill-relay-prod"
SMTP -> get_lines(): $str is "250-PIPELINING"
SMTP -> get_lines(): $data is "250-relay-2.ap-southeast-1.mandrill-relay-prod250-PIPELINING"
SMTP -> get_lines(): $data was "250-relay-2.ap-southeast-1.mandrill-relay-prod250-PIPELINING"
SMTP -> get_lines(): $str is "250-SIZE 26214400"
SMTP -> get_lines(): $data is "250-relay-2.ap-southeast-1.mandrill-relay-prod250-PIPELINING250-SIZE 26214400"
SMTP -> get_lines(): $data was "250-relay-2.ap-southeast-1.mandrill-relay-prod250-PIPELINING250-SIZE 26214400"
SMTP -> get_lines(): $str is "250-STARTTLS"
SMTP -> get_lines(): $data is "250-relay-2.ap-southeast-1.mandrill-relay-prod250-PIPELINING250-SIZE 26214400250-STARTTLS"
SMTP -> get_lines(): $data was "250-relay-2.ap-southeast-1.mandrill-relay-prod250-PIPELINING250-SIZE 26214400250-STARTTLS"
SMTP -> get_lines(): $str is "250-AUTH PLAIN LOGIN"
SMTP -> get_lines(): $data is "250-relay-2.ap-southeast-1.mandrill-relay-prod250-PIPELINING250-SIZE 26214400250-STARTTLS250-AUTH PLAIN LOGIN"
SMTP -> get_lines(): $data was "250-relay-2.ap-southeast-1.mandrill-relay-prod250-PIPELINING250-SIZE 26214400250-STARTTLS250-AUTH PLAIN LOGIN"
SMTP -> get_lines(): $str is "250-ENHANCEDSTATUSCODES"
SMTP -> get_lines(): $data is "250-relay-2.ap-southeast-1.mandrill-relay-prod250-PIPELINING250-SIZE 26214400250-STARTTLS250-AUTH PLAIN LOGIN250-ENHANCEDSTATUSCODES"
SMTP -> get_lines(): $data was "250-relay-2.ap-southeast-1.mandrill-relay-prod250-PIPELINING250-SIZE 26214400250-STARTTLS250-AUTH PLAIN LOGIN250-ENHANCEDSTATUSCODES"
SMTP -> get_lines(): $str is "250 8BITMIME"
SMTP -> get_lines(): $data is "250-relay-2.ap-southeast-1.mandrill-relay-prod250-PIPELINING250-SIZE 26214400250-STARTTLS250-AUTH PLAIN LOGIN250-ENHANCEDSTATUSCODES250 8BITMIME"
SERVER -> CLIENT: 250-relay-2.ap-southeast-1.mandrill-relay-prod250-PIPELINING250-SIZE 26214400250-STARTTLS250-AUTH PLAIN LOGIN250-ENHANCEDSTATUSCODES250 8BITMIME
CLIENT -> SERVER: AUTH LOGIN
SMTP -> get_lines(): $data was ""
bl abla
CLIENT -> SERVER:
CLIENT -> SERVER: .
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "250 2.0.0 Ok: queued as D1D682A0B20"
SMTP -> get_lines(): $data is "250 2.0.0 Ok: queued as D1D682A0B20"
SERVER -> CLIENT: 250 2.0.0 Ok: queued as D1D682A0B20
CLIENT -> SERVER: QUIT
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "221 2.0.0 Bye"
SMTP -> get_lines(): $data is "221 2.0.0 Bye"
SERVER -> CLIENT: 221 2.0.0 Bye
Connection: closed