【发布时间】: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 错误:无法验证。”
-
是的,“我们不授权...”消息只是“欢迎”横幅的一部分;这不是错误。