PHPMailer身份验证问题

问题描述:

我不知道我在做什么错或发生了什么,但我对发生了什么感到困惑。某些原因,我为pop-> Authorize传递的完全相同的登录信息在SMTP级别上被拒绝?PHPMailer身份验证问题

这里是我的连接代码

$username = '[email protected]'; 
$password = 'mypass'; 
$server = 'mail.mydomain.com'; 

$pop = new POP3(); 
$pop->Authorise($server, 110, 30, $username, $password, 1); 


$mail = new PHPMailer; 

$mail->SMTPDebug = 2;        // Enable verbose debug output 
echo "starting mailer..<br/>"; 
$mail->isSMTP();          // Set mailer to use SMTP 
$mail->Host = $server; // Specify main and backup SMTP servers 
$mail->SMTPAuth = true; 
$mail->SMTPSecure = 'tls';        // Enable SMTP authentication 
$mail->Username = $username;     // SMTP username 
$mail->Password = $password;       // SMTP password 
$mail->Port = 587;         // TCP port to connect to 

$mail->setFrom('[email protected]', 'Mailer'); 
$mail->addAddress('[email protected]', 'Joe User');  // Add a recipient 
$mail->isHTML(true);         // Set email format to HTML 

$mail->Subject = 'Here is the subject'; 
$mail->Body = 'This is the HTML message body <b>in bold!</b>'; 
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; 

if(!$mail->send()) { 
    echo 'Message could not be sent.'; 
    echo 'Mailer Error: ' . $mail->ErrorInfo; 
} else { 
    echo 'Message has been sent'; 
} 

下面是结果...

Server -> Client: +OK POP3 server ready <[email protected]> Server -> Client: +OK User:'[email protected]' ok Server -> Client: +OK Password ok 

由上述可知,它是使用POP登录

2016-02-12 16:38:05 SERVER -> CLIENT: 220-a2ls11.hosting.com ESMTP Exim 4.85 #2 Fri, 12 Feb 2016 11:38:05 -0500 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail. 
2016-02-12 16:38:05 CLIENT -> SERVER: EHLO mydomain.com 
2016-02-12 16:38:05 SERVER -> CLIENT: 250-a2ls11.hosting.com Hello a2ls11.hosting.com [75.98.175.122] 250-SIZE 52428800 250-8BITMIME 250-PIPELINING 250-AUTH PLAIN LOGIN 250-STARTTLS 250 HELP 
2016-02-12 16:38:05 CLIENT -> SERVER: STARTTLS 
2016-02-12 16:38:05 SERVER -> CLIENT: 220 TLS go ahead 
2016-02-12 16:38:05 CLIENT -> SERVER: EHLO mydomain.com 
2016-02-12 16:38:05 SERVER -> CLIENT: 250-a2ls11.hosting.com Hello a2ls11.hosting.com [75.98.175.122] 250-SIZE 52428800 250-8BITMIME 250-PIPELINING 250-AUTH PLAIN LOGIN 250 HELP 
2016-02-12 16:38:05 CLIENT -> SERVER: AUTH LOGIN 
2016-02-12 16:38:09 SERVER -> CLIENT: 334 VXNlcm5hbWU6 
2016-02-12 16:38:09 CLIENT -> SERVER: xxx 
2016-02-12 16:38:09 SERVER -> CLIENT: 334 UGFzc3dvcmQ6 
2016-02-12 16:38:09 CLIENT -> SERVER: yyy 
2016-02-12 16:38:11 SERVER -> CLIENT: 535 Incorrect authentication data 
2016-02-12 16:38:11 SMTP ERROR: Password command failed: 535 Incorrect authentication data 
2016-02-12 16:38:11 SMTP Error: Could not authenticate. 2016-02-12 16:38:11 CLIENT -> SERVER: QUIT 
2016-02-12 16:38:11 SERVER -> CLIENT: 221 a2ls11.hosting.com closing connection 
2016-02-12 16:38:11 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting 

我的意思是明确接受我究竟做错了什么?我无法理解我的生活。我甚至尝试过使用和不使用SMTPSecure。我尝试了端口25而不是587,但端口587与我在outlook中使用的端口完全相同。我很难过。

+0

您登录凭据作为base64字符串嵌入在该转储中。你最好去改变你的密码**立即**。 –

+0

哎呀大声笑感谢提供 – eqiz

+0

但嘿,至少你的密码(不是)“hunter42”或“密码”... –

显然这个问题是因为我拥有它的主机实际上不允许连接到外部SMTP服务器。疯狂的事情是,我没有从日志中得到错误,如上所示,它的行为就像登录信息不正确。我证实这是通过完全上传这个信息到另一台服务器的情况,它工作正常。

+1

这是涵盖在PHPMailer故障排除指南,它提到你应该检查你是否实际上连接到你认为你是的服务器。 – Synchro