简体   繁体   English

PHPMailer连接超时

[英]PHPMailer connection timed out

I am trying to use PHPMailer to send emails from my website. 我正在尝试使用PHPMailer从我的网站发送电子邮件。

Trying it locally on my PC, everything goes fine. 在我的PC上本地尝试,一切正常。

 SERVER -> CLIENT: 220 mail.xxx.it Microsoft ESMTP MAIL Service, Version: 6.0.3790.4675 ready at Sun, 26 Jan 2014 17:48:16 +0100 
CLIENT -> SERVER: EHLO localhost
SERVER -> CLIENT: 250-mail.xxx.it Hello [151.16.96.254]250-TURN250-SIZE250-ETRN250-PIPELINING250-DSN250-ENHANCEDSTATUSCODES250-8bitmime250-BINARYMIME250-CHUNKING250-VRFY250-X-EXPS GSSAPI NTLM LOGIN250-X-EXPS=LOGIN250-AUTH GSSAPI NTLM LOGIN250-AUTH=LOGIN250-X-LINK2STATE250-XEXCH50250 OK
CLIENT -> SERVER: MAIL FROM:<cantina@xxx.it>
SERVER -> CLIENT: 250 2.1.0 cantina@xxx.it....Sender OK
CLIENT -> SERVER: RCPT TO:<cantina@xxx.it>
SERVER -> CLIENT: 250 2.1.5 cantina@xxx.it 
CLIENT -> SERVER: DATA
SERVER -> CLIENT: 354 Start mail input; end with <CRLF>.<CRLF>
CLIENT -> SERVER: Date: Sun, 26 Jan 2014 16:48:16 +0000
CLIENT -> SERVER: Return-Path: <cantina@xxx.it>
CLIENT -> SERVER: To: Cantina <cantina@xxx.it>
CLIENT -> SERVER: From: Cantina<cantina@xxx.it>
CLIENT -> SERVER: Reply-To: Cantina <cantina@xxx.it>
CLIENT -> SERVER: Subject: PHPMailer Mail SMTP test
CLIENT -> SERVER: Message-ID: <7ce374d41e4d33734ece535a61122792@localhost>
CLIENT -> SERVER: X-Priority: 3
CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.7 (https://github.com/PHPMailer/PHPMailer/)
CLIENT -> SERVER: MIME-Version: 1.0
CLIENT -> SERVER: Content-Type: multipart/alternative;
CLIENT -> SERVER: boundary="b1_7ce374d41e4d33734ece535a61122792"
...    
SERVER -> CLIENT: 250 2.6.0 <7ce374d41e4d33734ece535a61122792@localhost> Queued mail for delivery
CLIENT -> SERVER: QUIT
SERVER -> CLIENT: 221 2.0.0 mail.xxx.it Service closing transmission channel
Message sent!

While when I move my PHP file to the webserver on the hosting provider. 当我将我的PHP文件移动到托管提供程序上的Web服务器时。

SMTP ERROR: Failed to connect to server: Connection timed out (110)
SMTP connect() failed.
Mailer Error: SMTP connect() failed.

The SMTP is responsing on standard 25 non authenticated. SMTP对标准25未经身份验证的设备进行响应。

Any hint on how to go further on the understanding on why it happens. 关于如何进一步了解发生原因的任何提示。 I would start by pinging the machine, I don't know if it could be done via PHP. 我将从对计算机执行ping操作开始,我不知道是否可以通过PHP完成。

Thank you 谢谢

Yes you can ping with php, here's an example: 是的,您可以使用php ping通,这是一个示例:

function ping($host, $port, $timeout) { 
  $tB = microtime(true); 
  $fP = fSockOpen($host, $port, $errno, $errstr, $timeout); 
  if (!$fP) { return "down"; } 
  $tA = microtime(true); 
  return round((($tA - $tB) * 1000), 0)." ms"; 
}

//Echoing it will display the ping if the host is up, if not it'll say "down".
echo ping("xxx.it", 25, 10);

I'm sure this isn't enough to solve your problem but it will, at least, help you to determine if you can connect to the remote serve before continuing with the rest of the script. 我确定这还不足以解决您的问题,但至少可以帮助您在继续执行其余脚本之前确定是否可以连接到远程服务。
You should also consider that the remote server maybe be blocking connections for your host. 您还应该考虑到远程服务器可能正在阻止主机的连接。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM