无法连接到SMTP主机PHP Mailer

时间:2015-06-19 08:56:32

标签: php email ssl

我使用phpmailer发送电子邮件。这是我的代码。

require 'PHPMailerAutoload.php';

$mail = new PHPMailer;

$mail->SMTPDebug = 1;
$mail->isSMTP();                                      
$mail->Host = 'mail.distech.com.my';                    
$mail->SMTPAuth = true;                               
$mail->Username = 'myemail';                  
$mail->Password = 'mypassword';                          
$mail->SMTPSecure = 'tls';                          
$mail->Port = 587; 

我已经在我的计算机上使用了这段代码,但它确实有用。电子邮件已发送。但是,当我在朋友计算机上运行此代码时,会出现错误。

错误:

2015-06-19 08:42:12 CLIENT -> SERVER: EHLO 192.168.1.20 
2015-06-19 08:42:12 CLIENT -> SERVER: STARTTLS  Warning: stream_socket_enable_crypto() [function.stream-socket-enable-crypto]: SSL: The operation completed successfully. in C:\xampp\htdocs\ehars\phpmailer\class.smtp.php on line 344 
2015-06-19 08:42:12 SMTP Error: Could not connect to SMTP host. 
2015-06-19 08:42:12 CLIENT -> SERVER: QUIT  Notice: fwrite() [function.fwrite]: send of 6 bytes failed with errno=10054 An existing connection was forcibly closed by the remote host. in C:\xampp\htdocs\ehars\phpmailer\class.smtp.php on line 937 
2015-06-19 08:42:12 SMTP ERROR: QUIT command failed: 
2015-06-19 08:42:12 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

因为我是phpmailer的新手,可能会出现什么问题。我曾尝试在两台计算机上ping mail.distech.com.my,两者都完美无缺。请帮帮我谢谢。

1 个答案:

答案 0 :(得分:1)

您可以尝试升级PHP版本。

同样在php.ini文件中启用以下行并重启apche服务器。

; extension=php_openssl.dll