Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么phpMailer只在本地服务器上工作?_Php_Smtp_Localhost_Phpmailer - Fatal编程技术网

为什么phpMailer只在本地服务器上工作?

为什么phpMailer只在本地服务器上工作?,php,smtp,localhost,phpmailer,Php,Smtp,Localhost,Phpmailer,我有一个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

我有一个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.

这是什么区别?我该如何解决它呢?

与凭据无关-它还没有达到尝试它们的程度。阅读故障排除指南-您遇到TLS问题,很可能是您的CA证书已过期。

您是否检查了凭据是否正确?
sample domain.com
正在显示什么或您正在编辑什么?它使用的端口可能在您的远程服务器上被阻止。从未检查连接后的凭据@lawrencerone。检查您的主机是否未阻止端口许多主机都会这样做抱歉,该选项是sample-domain.com或25正确,而不仅仅是用户密码。@LawrenceCherone
simple-domain.com
只是一个示例。我的代码里有真实的信息。凭据是正确的,因为我可以通过localhost发送电子邮件