简体   繁体   中英

Could not connect to SMTP host PHP Mailer

I'm using phpmailer to send email. 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. I have tried pinging mail.distech.com.my on both computer and both works perfectly fine. Please help me thank you.

You can try with upgrading PHP version.

As well enable below line in php.ini file and restart apche server.

; extension=php_openssl.dll

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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