我正在使用 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;
我已经在我的电脑上使用了这段代码并且它有效。电子邮件已发送。但是,当我在 friend 的计算机上运行这段代码时,出现错误。
错误:
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 并且都工作得很好。请帮助我,谢谢。
最佳答案
您可以尝试升级 PHP 版本。
同时在 php.ini 文件中启用以下行并重新启动 apche 服务器。
; extension=php_openssl.dll
关于php - 无法连接到 SMTP 主机 PHP Mailer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30933981/