为什么PhpMailer会在某些机器上崩溃?

时间:2016-03-16 10:24:50

标签: php phpmailer

我正在使用PHPMailer发送电子邮件。我的问题是,从我的电脑上一切正常,但在其他设备上,如其他人的笔记本电脑或PC出现以下错误:

SMTP Error: Could not authenticate. Mailer Error: SMTP Error: Could not authenticate.The following From address failed: confidential@confidential.com Mailer Error: The following From address failed: confidential@confidential.com 

SMTP服务器错误:未公布时使用的AUTH命令

有人可以对这个问题有所了解吗?!

我的代码:

$mail             = new PHPMailer(); // defaults to using php "mail()"

$body             = stripslashes($_POST['textarea']);
$body = str_replace(' ',' ',$body);
$body = str_replace('/media/','http://www.confidential.com/media/', $body);
$body = $body;

//$body             = eregi_replace("[\]",'',$body);

    $mail->From       = "confidential@confidential.com";
    $mail->FromName   = "confidential confidential";
    $mail->CharSet  = 'UTF-8';
    $mail->Subject    = $_POST['subject'];
    //$mail->IsSMTP(); // telling the class to use SMTP
    //$mail->Host       = "confidential.com"; // SMTP server    
    //$mail->SMTPAuth   = false;                  // enable SMTP authentication 
    //$mail->Port       = 25;                    // set the SMTP port for the GMAIL server
    //$mail->Username   = "confidential@confidential.com"; // SMTP account username
    //$mail->Password   = "confidential";        // SMTP account password
    $mail->SetFrom('confidential@confidential.com', 'confidential confidential');
    $mail->AddReplyTo("confidential@confidential.com","confidential confidential");     
    //$mail->SMTPDebug = 1;

此外,当我使用SMTP身份验证时,我在每个设备上都有以下错误:

SMTP Error: Could not authenticate. Mailer Error: SMTP Error: Could not authenticate.SMTP Error: The following recipients failed: someemail@test.com Mailer Error: SMTP Error: The following recipients failed: someemail@test.com

SMTP服务器错误:身份验证失败

更新

导致完整错误:

SMTP -> FROM SERVER:220-sclabo15.ds.systemsunit.com ESMTP Exim 4.86_1 #1 Wed, 16 Mar 2016 13:10:25 +0200 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
SMTP -> FROM SERVER: 250-sclabo15.ds.systemsunit.com Hello confidential.com [176.223.213.66] 250-SIZE 52428800 250-8BITMIME 250-PIPELINING 250-AUTH PLAIN LOGIN 250-STARTTLS 250 HELP
SMTP -> ERROR: Password not accepted from server: 535 Incorrect authentication data
SMTP -> FROM SERVER:250 Reset OK
SMTP Error: Could not authenticate. Mailer Error: SMTP Error: Could not authenticate.SMTP -> FROM SERVER:250 OK
SMTP -> FROM SERVER:550 Authentication failed
SMTP -> ERROR: RCPT not accepted from server: 550 Authentication failed
SMTP Error: The following recipients failed: confidential@confidential.com Mailer Error: SMTP Error: The following recipients failed: confidential@confidential.com

SMTP server error: Authentication failed 

2 个答案:

答案 0 :(得分:0)

  

密码是否使用任何非ASCII字符? - Martin @Martin,

     

如果'#'是非ASCII,然后是。 - 匿名

您的问题可能是您的密码包含#字符。这个角色有点痛苦,因为它并不适合安全"但实际上并没有通过许多清洁功能去除或清洁。它是一个URL地址特殊字符,并且反复出现类似SMTP错误的原因:

https://sourceforge.net/p/davmail/bugs/539/

https://meta.discourse.org/t/bug-smtp-password-field-does-not-escape-comment-sign-hash/23344/6

还要检查字符串编码以获取用户名和密码字符串。您对$mail->CharSet = 'UTF-8'; 的引用可能导致PHPMailer对SMTP的密码进行编码(我不确定)。

http://www.easy-smtp.com/smtp-troubleshooting-guide

还有其他各种敲门事件,例如您将被阻止从服务器进行许多失败的身份验证尝试。令人沮丧,但需要注意。

http://www.fehcom.de/qmail/smtpauth.html http://www.samlogic.net/articles/smtp-commands-reference-auth.htm

<强>解决方案: 调试并更改密码,使其不包含#字符,看看是否可以改善您的情况。但请注意您可能因为太多错误登录而被阻止,并且您需要等待一段时间才能再次与SMTP服务器建立连接。

答案 1 :(得分:-1)

$mail->SMTPDebug = 2;启用SMTP调试信息(用于测试)