SMTP 连接()失败。发送认证邮件时

Posted

技术标签:

【中文标题】SMTP 连接()失败。发送认证邮件时【英文标题】:SMTP connect() failed. While Sending Authentication Email 【发布时间】:2017-11-08 07:36:48 【问题描述】:

我正在尝试使用 php mailer 通过 php 发送电子邮件,但它显示 SMTP connect() 失败。这是我的代码。无法找出问题所在。如果有人帮助跟踪错误,这对我很有帮助。

$mail = new PHPMailer;

$mail->isSMTP();                                   // Set mailer to use SMTP
$mail->Host = 'dds.uemtv.com';                    // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                            // Enable SMTP authentication
$mail->Username = 'no-reply@domain.com';          // SMTP username
$mail->Password = 'pssword'; // SMTP password
$mail->SMTPSecure = 'tls';                         // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;                                 // TCP port to connect to

$mail->setFrom('no-reply@domain.com', 'title');
$mail->addReplyTo($email, '$name');
$mail->addAddress($email);   // Add a recipient
//$mail->addCC('cc@example.com');
//$mail->addBCC('bcc@example.com');

$mail->ishtml(true);  // Set email format to HTML


$bodyContent = '<h1>Your Registration Completed. </h1>'
$mail->Subject = 'Verify Account- Rozgar';
$mail->Body    = $bodyContent;
if(!$mail->send()) 

    echo $data->msg = $mail->ErrorInfo;
 else 
    // echo 'Message has been sent';
    echo $data->msg="Please Verify Your Email Address";

显示此错误。

2017-06-07 05:36:44 SERVER -> CLIENT: 220-dds.uemtv.com ESMTP Exim 4.89 #1 Wed, 07 Jun 2017 10:36:40 +0500 220-我们不授权使用该系统用于传输未经请求的 220 和/或批量电子邮件。 2017-06-07 05:36:44 客户端 -> 服务器:EHLO 本地主机 2017-06-07 05:36:44 服务器 -> 客户端:250-dds.uemtv.com 你好 localhost [182.186.132.245] 250-SIZE 52428800 250-8BITMIME 250-PIPELINING 250-STARTTLS 250 帮助 2017-06-07 05:36:44 客户端 -> 服务器:STARTTLS 2017-06-07 05:36:45 服务器 -> 客户端:220 TLS 继续 2017-06-07 05:36:46 客户端 -> 服务器:EHLO 本地主机 2017-06-07 05:36:47 服务器 -> 客户端:250-dds.uemtv.com 你好 localhost [182.186.132.245] 250-SIZE 52428800 250-8BITMIME 250-PIPELINING 250-AUTH PLAIN LOGIN 250 帮助 2017-06-07 05:36:47 客户端 -> 服务器:授权登录 2017-06-07 05:36:47 服务器 -> 客户端:334 VXNlcm5hbWU6 2017-06-07 05:36:47 客户端 -> 服务器:xxx= 2017-06-07 05:36:47 服务器 -> 客户端:334 UGFzc3dvcmQ6 2017-06-07 05:36:47 客户端 -> 服务器:xxx 2017-06-07 05:36:49 服务器 -> 客户端:535 身份验证数据不正确 2017-06-07 05:36:49 SMTP 错误:密码命令失败:535 身份验证数据不正确 2017-06-07 05:36:49 SMTP 错误:无法验证。 2017-06-07 05:36:49 客户端 -> 服务器:退出 2017-06-07 05:36:50 服务器 -> 客户端:221 dds.uemtv.com 关闭连接 2017-06-07 05:36:50 SMTP 连接()失败。 https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting SMTP 连接()失败。 https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

【问题讨论】:

问题在日志中。来自 SMTP 服务器的消息:“我们不授权使用此系统来传输未经请求的 220 和/或批量电子邮件”。该代码有效,您只是被 SMTP 服务器阻止了。 我认为这不是错误,错误在 535 不正确的身份验证数据部分所在的位置进一步下降。 @DavidFindlay 哦,看那个。你完全正确:“SMTP 错误:无法验证。” 是的,“我们不授权...”消息只是“欢迎”横幅的一部分;这不是错误。 【参考方案1】:

这似乎不是代码问题, 因此,我们无法为您解决问题。 与您的 ISP 交谈,阅读他们的文档。

所以要么你的主机设置错误,要么你被重定向 您的 ISP。无论哪种方式,这都在the troubleshooting guide 中涵盖了您所指出的错误消息,这就是它存在的原因。

【讨论】:

【参考方案2】:

您的代码可能没有任何问题。您使用的服务器不允许未经身份验证的中继。您的日志中存在身份验证错误,因此您可能使用了不正确的凭据。

【讨论】:

仔细检查了所有内容,凭据正确,但仍然显示此错误 错误是身份验证失败。尝试使用普通的电子邮件客户端。 @ImranIqbal 日志不同意。“SMTP 错误:无法验证。”。请与您的托管服务提供商联系以获取电子邮件。

以上是关于SMTP 连接()失败。发送认证邮件时的主要内容,如果未能解决你的问题,请参考以下文章

关于java使用网易服务器smtp.163.com发送邮件,连接失败的问题

java mail 发邮件连接不上smtp服务器怎么办

SMTP Connect() 失败。邮件未发送。邮件程序错误:SMTP Connect() 失败

腾讯云服务器使用smtp发送邮件

foxmail测试结果为登陆到发送邮件服务器(smtp):smtp server reply:535 authentic

PHPmailer:SMTP 连接()失败(不工作)