PHPMailer连接超时

时间:2014-01-26 17:12:43

标签: php phpmailer web-hosting

我正在尝试使用PHPMailer从我的网站发送电子邮件。

在我的电脑上尝试本地化,一切都很顺利。

 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!

当我将PHP文件移动到托管服务提供商的网络服务器时。

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

SMTP对标准25未经过身份验证负责。

有关如何进一步了解其发生原因的任何提示。 我首先要ping机器,我不知道是否可以通过PHP完成。

谢谢

1 个答案:

答案 0 :(得分:1)

是的你可以用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);

我确信这还不足以解决您的问题,但它至少可以帮助您确定是否可以在继续使用其余脚本之前连接到远程服务器。
您还应该考虑远程服务器可能阻止主机的连接。