PhpMailer:SMTP错误:EHLO命令失败 [英] PhpMailer: SMTP ERROR: EHLO command failed

查看:427
本文介绍了PhpMailer:SMTP错误:EHLO命令失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在受管服务器上使用PhpMailer(我只能通过cPanel访问),而且我收到这个错误:

I'm trying to use the PhpMailer on a managed server (I only have access via cPanel), and I'm getting this error:

SERVER -> CLIENT:
CLIENT -> SERVER: EHLO stefanomenci.com
SERVER -> CLIENT: HTTP/1.1 301 Moved
 [...]
SMTP ERROR: EHLO command failed: HTTP/1.1 301 Moved

这是脚本:

require ("/path/to/class.phpmailer.php");
$mail = new PHPMailer();
$mail->SMTPDebug = 2;
$mail->IsSMTP();
$mail->Host = "mydomain.com";
$mail->Port = 2096;
$mail->SMTPAuth = true;
$mail->Username = "name@mydomain.com";
$mail->Password = "****";
$mail->From = "name@mydomain.com";
$mail->FromName = "Name";
$mail->AddAddress("myaddress@gmail.com");
$mail->WordWrap = 50;
$mail->IsHTML(true);
$mail->Subject = "Subject";
$mail->Body = "y<b>a</b>y";
$mail->AltBody = "yay";
$mail->Send();

如果端口错误,它将立即失败,无法连接到服务器。

If port is wrong it fails immediately with "failed to connect to the server".

如果端口丢失,则说请在邮件客户端中打开SMTP验证,或者在发送邮件之前登录到服务器。

If port is missing it says "Please turn on SMTP Authentication in your mail client, or login to the server before sending your message."

如果端口正确,请等待10秒钟,并显示上述错误,无论用户名和密码是否正确。

If port is correct it waits 10 seconds and shows the error shown above, regardless of the user name and password being correct or not.

删除 $ mail-> IsSMTP()工作,但通常电子邮件直接发送到垃圾邮件文件夹。

Removing $mail->IsSMTP() works, but often the emails go straight to the spam folder.

我发现很多帖子关于PhpMailer的类似问题,但他们通常使用Google而不是mydomain.com,他们从不会出现此错误消息。

I found many posts about similar problem with PhpMailer, but they usually use Google instead of mydomain.com and they never have this error message.

推荐答案

使用如上所述的端口25或465。在端口2096正在运行Web服务器,我们可以在连接中看到(SERVER - > CLIENT:HTTP / 1.1 301 Moved)。

Use either port 25 or 465 as mentioned above. On port 2096 is running a webserver as we can see in the connection ( SERVER -> CLIENT: HTTP/1.1 301 Moved ).

这篇关于PhpMailer:SMTP错误:EHLO命令失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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