一旦我把它放在服務器上,我有類似的代碼工作在我的本地環境,它的作品完美,任何想法下面的代碼不工作?Google SMTP錯誤:無法驗證
編輯:我沒有把我的Gmail設置爲「不太安全」
<?php
$setid = $_POST['setid'];
$promo = $_POST['promo'];
echo "Good Sir, your set ID is ".$setid.", and you are eligible for the following deal:";
echo "<br><br>";
echo $promo;
$message= "Good Sir, your set ID is ".$setid.", and you are eligible for the following deal:"."<br><br>".$promo;
require "phpmailer/class.phpmailer.php";
// Instantiate Class
$mail = new PHPMailer();
// Set up SMTP
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Encoding = '7bit';
// Authentication
$mail->Username = "[email protected]";
$mail->Password = "mypass";
// Compose
$mail->SetFrom("[email protected]");
$mail->AddReplyTo("[email protected]");
$mail->Subject = "TryIt";
$mail->MsgHTML($message);
// Send To
$mail->AddAddress("[email protected]", "Recipient Name");
$result = $mail->Send();
$message = $result ? 'Successfully Sent!' : 'Sending Failed!';
unset($mail);
?>
這是我在網絡上獲取 - >預覽:
好先生,您所設定的ID是100065,你有資格獲得以下優惠:
當前促銷:享受下次訪問的15%折扣!SMTP錯誤:無法進行身份驗證。
我希望你沒有在這裏發佈真正的密碼...''''mail-> Password =「你的密碼」' –
你正在使用PHPMailer的一個非常舊的版本,而你沒有[閱讀文檔]( https://github.com/PHPMailer/PHPMailer/wiki)。 – Synchro
[「PHP錯誤:無法驗證」PHPMailer中可能的重複](http://stackoverflow.com/questions/3949824/smtp-error-could-not-authenticate-in-phpmailer) – Synchro