简体   繁体   English

无法连接到SMTP主机PHP Mailer

[英]Could not connect to SMTP host PHP Mailer

I'm using phpmailer to send email. 我正在使用phpmailer发送电子邮件。 This is my code. 这是我的代码。

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; 

I've used this code on my computer and it works. 我已经在计算机上使用了此代码,并且可以正常工作。 The email is been send. 电子邮件已发送。 However, when I run this code on my friends computer, an error appears. 但是,当我在朋友计算机上运行此代码时,出现错误。

The error : 错误 :

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

What could be the problem as I am new to phpmailer. 可能是什么问题,因为我是phpmailer的新手。 I have tried pinging mail.distech.com.my on both computer and both works perfectly fine. 我已经尝试在两台计算机上ping mail.distech.com.my,并且两者都运行良好。 Please help me thank you. 请帮我谢谢。

You can try with upgrading PHP version. 您可以尝试升级PHP版本。

As well enable below line in php.ini file and restart apche server. 以及启用php.ini文件中的以下行并重新启动apche服务器。

; extension=php_openssl.dll

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

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