我正在使用PHPMailer发送电子邮件。我的问题是,从我的PC上一切正常,但是在其他设备上,例如其他人的笔记本电脑或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
您的密码是否使用任何非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.htmlhttp://www.samlogic.net/articles/smtp-commands-reference-auth.htm
溶液:调试并更改密码以不包含#
字符,看看这是否会改善您的情况。但请注意,您可能会因太多错误登录而被阻止,您需要等待一段时间才能再次与 SMTP 服务器建立清晰的连接。
$mail->SMTPDebug = 2;
启用SMTP调试信息(用于测试)