0
<?php
require_once ("PHPMailer-master/PHPMailerAutoload.php");
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
//$mail->SMTPSecure = 'tls';
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "[email protected]";
$mail->Password = "abcpassword";
$mail->SetFrom("[email protected]");
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress("[email protected]");
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
}
?>
我得到的消息:郵件錯誤:SMTP連接()通過SMTP的Gmail失敗,PHPMailer的
2015-07-11 08:06:17 CLIENT -> SERVER: EHLO action.ticambodia.org
2015-07-11 08:06:17 CLIENT -> SERVER: AUTH LOGIN
2015-07-11 08:06:17 CLIENT -> SERVER: c29lbmdrYW5lbEBnbWFpbC5jb20=
2015-07-11 08:06:17 CLIENT -> SERVER: a2FuZWxAbjB3 2015-07-11 08:06:17 SMTP ERROR: Password command failed: 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 mg19sm5958238oeb.10 - gsmtp
2015-07-11 08:06:17 SMTP Error: Could not authenticate.
2015-07-11 08:06:17 CLIENT -> SERVER: QUIT
2015-07-11 08:06:17 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
任何人,可以幫助找出是什麼問題,如何解決呢?
錯誤似乎很明顯 – 2015-07-11 08:16:18
如果您表現出絲毫嘗試自己解決問題,尤其是當好的建議坐在您面前時,您會獲得更多的同情。 **閱讀您的錯誤信息**。如果您按照所提供的文檔鏈接,它會完全告訴您*您需要做什麼來解決您的問題。您還將代碼基於舊示例 - 確保您使用的是最新的PHPMailer。 – Synchro