PHPMailer:SMTP错误:无法连接到SMTP主机 [英] PHPMailer: SMTP Error: Could not connect to SMTP host

查看:550
本文介绍了PHPMailer:SMTP错误:无法连接到SMTP主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在几个项目中使用了PHPMailer,但现在我被卡住了。它给我错误:

SMTP错误:无法连接到SMTP主机。

我已经尝试从Thunderbird发送电子邮件,它的工作原理!但不是通过PHPMailer ...这里是Thunderbird的设置:

I've used PHPMailer on several projects but now I'm stuck. It gives me the error:
SMTP Error: Could not connect to SMTP host.
I've tried sending email from Thunderbird and it works ! But not through PHPMailer ... Here are the settings from Thunderbird:

服务器名称:mail.exampleserver.com

端口:587

用户名:user@exampleserver.com

安全认证:否

连接安全性:STARTTLS

我在最后一个使用PHPMailer的项目中将这些与服务器进行了比较,他们是:

I've compared these with the server at my last project where I used PHPMailer and they were:

服务器名称:mail.exampleserver2。 com

端口:465

用户名:user@exampleserver2.com

安全认证:否

连接安全性:SSL / TLS

我的PHP代码是:

 $mail = new PHPMailer();
 $mail->IsSMTP(); // send via SMTP
 $mail->Host = SMTP_HOST; // SMTP servers
 $mail->Port = SMTP_PORT; // SMTP servers
 $mail->SMTPAuth = true; // turn on SMTP authentication
 $mail->Username = SMTP_USER; // SMTP username
 $mail->Password = SMTP_PASSWORD; // SMTP password
 $mail->From = MAIL_SYSTEM;
 $mail->FromName = MAIL_SYSTEM_NAME;
 $mail->AddAddress($aSecuredGetRequest['email']);
 $mail->IsHTML(true); // send as HTML

我错了什么?

推荐答案

在我的情况下,PHP中缺少SSL支持,给出了这个错误。

In my case it was a lack of SSL support in PHP which gave this error.

所以我启用了 extension = php_openssl.dll

$ mail-> SMTPDebug = 1; 还暗示

更新2017

$ mail-> SMTPDebug = 2; ,请参阅: https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting#enabling-debug-output

这篇关于PHPMailer:SMTP错误:无法连接到SMTP主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆