2017-06-07 81 views
0

我试图通过使用PHP邮件通过PHP发送电子邮件,但它显示SMTP连接()失败。这是我的代码。无法找出那是什么问题。如果有人帮助追踪错误,那对我来说会非常有帮助。SMTP连接()失败。虽然发送身份验证电子邮件

$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 = '[email protected]';   // 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('[email protected]', 'title'); 
$mail->addReplyTo($email, '$name'); 
$mail->addAddress($email); // Add a recipient 
//$mail->addCC('[email protected]'); 
//$mail->addBCC('[email protected]'); 

$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-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
2017-06-07 05:36:44 CLIENT -> SERVER: EHLO localhost
2017-06-07 05:36:44 SERVER -> CLIENT: 250-dds.uemtv.com Hello localhost [182.186.132.245] 250-SIZE 52428800 250-8BITMIME 250-PIPELINING 250-STARTTLS 250 HELP
2017-06-07 05:36:44 CLIENT -> SERVER: STARTTLS
2017-06-07 05:36:45 SERVER -> CLIENT: 220 TLS go ahead
2017-06-07 05:36:46 CLIENT -> SERVER: EHLO localhost
2017-06-07 05:36:47 SERVER -> CLIENT: 250-dds.uemtv.com Hello localhost [182.186.132.245] 250-SIZE 52428800 250-8BITMIME 250-PIPELINING 250-AUTH PLAIN LOGIN 250 HELP
2017-06-07 05:36:47 CLIENT -> SERVER: AUTH LOGIN
2017-06-07 05:36:47 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2017-06-07 05:36:47 CLIENT -> SERVER: xxx=
2017-06-07 05:36:47 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2017-06-07 05:36:47 CLIENT -> SERVER: xxx
2017-06-07 05:36:49 SERVER -> CLIENT: 535 Incorrect authentication data
2017-06-07 05:36:49 SMTP ERROR: Password command failed: 535 Incorrect authentication data
2017-06-07 05:36:49 SMTP Error: Could not authenticate.
2017-06-07 05:36:49 CLIENT -> SERVER: QUIT
2017-06-07 05:36:50 SERVER -> CLIENT: 221 dds.uemtv.com closing connection
2017-06-07 05:36:50 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

+0

问题出现在日志中。来自SMTP服务器的消息:_“我们不授权使用此系统传输未经请求的,220和/或批量电子邮件”_。代码正常工作,你只是被SMTP服务器阻止。 –

+0

我不认为这是错误,535错误的认证数据部分错误进一步下降。 –

+0

@DavidFindlay哦,看看那个。您绝对正确:_“SMTP错误:无法进行身份验证。”_ –

回答

1

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

+0

双重检查了所有内容和凭据是正确的,但仍显示此错误 –

+0

错误是身份验证失败。试用普通的电子邮件客户端。 –

+0

@ImranIqbal日志不同意.. _“SMTP错误:无法验证。”_。与您的主机提供商联系以获取电子邮件。 –

1

它似乎不是一个代码问题, 因此不是我们可以为您解决的问题。 与您的ISP交谈,阅读他们的文档。

So either your Host setting is wrong, or you are being redirected by your ISP. Either way, this is all covered in the troubleshooting guide the error message pointed you at, which is why it's there.

相关问题