php - 无法连接到 SMTP 主机 PHP Mailer

标签 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; 

我已经在我的电脑上使用了这段代码并且它有效。电子邮件已发送。但是,当我在 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/

相关文章:

c++ - 为游戏数据流量添加 SSL 加密是否值得?

javascript - 页面加载时自动提交表单导致无限循环

php - 使用 Jquery BlueImp uploader 上传大文件后出现延迟

Android 联系人选择器获取姓名 + 号码 + 电子邮件

android - 如何在 Android 上创建电子邮件按钮?

c# - 尝试远程连接时远程证书无效

ruby-on-rails - AWS Certificate Manager - SSL 表示正在使用,但 HTTPS 不起作用

php - 获取日期时间当天的所有结果

php - 使用 jQuery AJAX 通过 FormData 上传文件

c# - 如何将 smtp 发送功能添加到我的应用程序