【问题标题】:Could not connect to SMTP host PHP Mailer无法连接到 SMTP 主机 PHP Mailer
【发布时间】:2015-06-19 08:56:31
【问题描述】:

我正在使用 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 并且都工作得很好。请帮帮我,谢谢。

【问题讨论】:

标签: php email ssl


【解决方案1】:

您可以尝试升级PHP版本。

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

; extension=php_openssl.dll

【讨论】:

  • 我已经在 php.ini 中启用了上述行。它仍然是一样的。会不会是旧的 xampp 版本会导致这个问题?
  • 有可能,可以升级PHP版本。
  • 向 php.ini 添加扩展为我解决了(php 5.3.4)
猜你喜欢
  • 1970-01-01
  • 2012-04-12
  • 2014-05-01
  • 1970-01-01
  • 1970-01-01
  • 2016-05-02
  • 2012-05-24
  • 2012-06-17
相关资源
最近更新 更多