一旦我把它放在服务器上,我有类似的代码工作在我的本地环境,它的作品完美,任何想法下面的代码不工作?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