【发布时间】:2018-08-13 14:22:05
【问题描述】:
我有一个 PHP 文件,它使用 phpMailer 通过 SMTP 发送电子邮件。当我在本地主机(使用 Xampp)上使用它时,它运行良好。但是当我将同一个文件放在远程服务器上时,它会返回错误并且不会发送任何电子邮件。
2018-03-05 20:12:44 SERVER -> CLIENT:
2018-03-05 20:12:44 CLIENT -> SERVER: EHLO sample-domain.com
2018-03-05 20:12:44 SERVER -> CLIENT:
2018-03-05 20:12:44 SMTP ERROR: EHLO command failed:
2018-03-05 20:12:44 CLIENT -> SERVER: HELO sample-domain.com
2018-03-05 20:12:44 SERVER -> CLIENT:
2018-03-05 20:12:44 SMTP ERROR: HELO command failed:
2018-03-05 20:12:44 CLIENT -> SERVER: STARTTLS
2018-03-05 20:12:44 SERVER -> CLIENT:
2018-03-05 20:12:44 SMTP ERROR: STARTTLS command failed:
SMTP Error: Could not connect to SMTP host.
2018-03-05 20:12:44 CLIENT -> SERVER: QUIT
2018-03-05 20:12:44 SERVER -> CLIENT:
2018-03-05 20:12:44 SMTP ERROR: QUIT command failed:
SMTP Error: Could not connect to SMTP host.
Message could not be sent. Mailer Error: SMTP Error: Could not connect to SMTP host.
这个区别有什么用?我该如何解决?
【问题讨论】:
-
您是否检查过凭据是否正确?
sample-domain.com是正在显示的内容还是您正在编辑的内容? -
它使用的端口可能在您的远程服务器上被阻止。
-
从来没有检查连接后的凭据@LawrenceCherone。检查你的主机没有阻塞端口很多主机都这样做
-
对不起,我认为 sample-domain.com 或 25 正确,而不仅仅是用户密码。
-
@LawrenceCherone
simple-domain.com只是这里的一个示例。我的代码中有真实的信息。凭据是正确的,因为我可以通过 localhost 与他们发送电子邮件
标签: php smtp localhost phpmailer