1
我遇到了phpMailer的問題。它在本地主機上正常工作,但在將其上傳到Web主機時會出現身份驗證錯誤。用phpMailer發送郵件,但在本地主機上工作
「客戶:535個不正確的認證數據」
的設置爲smtp.gmail.com,端口587,使用TLS加密上http://email.about.com/od/accessinggmail/f/Gmail_SMTP_Settings.htm
如說我取代了真正的網站地址與www.mywebsiteaddress.com 。
這裏:
2014-08-28 22:55:00 SERVER -> CLIENT: 220-lp.linkdatacenter.net ESMTP Exim 4.82 #2 Thu, 28 Aug 2014 22:55:00 +0000 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
2014-08-28 22:55:00 CLIENT -> SERVER: EHLO www.mywebsiteaddress.com
2014-08-28 22:55:00 SERVER -> CLIENT: 250-lp.linkdatacenter.net Hello sigmaengco.com [213.131.64.210] 250-SIZE 52428800 250-8BITMIME 250-PIPELINING 250-AUTH PLAIN LOGIN 250-STARTTLS 250 HELP
2014-08-28 22:55:00 CLIENT -> SERVER: STARTTLS
2014-08-28 22:55:00 SERVER -> CLIENT: 220 TLS go ahead
2014-08-28 22:55:00 CLIENT -> SERVER: EHLO www.mywebsiteaddress.com
2014-08-28 22:55:00 SERVER -> CLIENT: 250-lp.linkdatacenter.net Hello sigmaengco.com [213.131.64.210] 250-SIZE 52428800 250-8BITMIME 250-PIPELINING 250-AUTH PLAIN LOGIN 250 HELP 2014-08-28 22:55:00 CLIENT -> SERVER: AUTH LOGIN
2014-08-28 22:55:00 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2014-08-28 22:55:00 CLIENT -> SERVER: bGl0dGxlcGVhcmxzY2VudGVyQGdtYWlsLmNvbQ==
2014-08-28 22:55:00 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2014-08-28 22:55:00 CLIENT -> SERVER: dXRvcGlhdXRvcGlh
2014-08-28 22:55:02 SERVER -> CLIENT: 535 Incorrect authentication data
2014-08-28 22:55:02 SMTP ERROR: Password command failed: 535 Incorrect authentication data
2014-08-28 22:55:02 CLIENT -> SERVER: QUIT
2014-08-28 22:55:02 SERVER -> CLIENT: 221 lp.linkdatacenter.net closing connection
SMTP connect() failed. Message could not be sent.Mailer Error: SMTP connect() failed.
這裏是代碼的相關部分,我換成用假信息的真實信息。
require_once('PHPMailer-master/PHPMailerAutoload.php');
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPDebug = 2;
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = 'mypassword'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
$mail->Port = 587; // set the SMTP port for the GMAIL
$mail->From = '[email protected]';
$mail->FromName = 'my website name';
//$mail->addAddress('[email protected]', 'Joe User'); // Add a recipient
$mail->addAddress('[email protected]'); // Name is optional
$mail->addReplyTo($email, $name);
這應該給你的失敗原因的一個好主意:'SMTP錯誤:密碼命令失敗:535個不正確的認證數據2014年8月28日22:55:02' – 2014-09-02 06:38:13
@歐萊雅L'L,則在本地主機上使用的相同的確切密碼工作正常。它與網絡託管服務器上的設置有關。 – Amzraptor 2014-09-02 06:45:40
用於測試:您的密碼不應包含特殊字符和變音符號。 – 2014-09-02 06:51:16