【发布时间】:2015-07-26 13:00:29
【问题描述】:
我知道这个问题已经被问过很多次了。但解决方案似乎对我没有帮助。所以我特此发布我的代码:
<?php
require("class.phpmailer.php");
require("class.smtp.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host="smtp.gmail.com";
$mail->SMTPDebug=1;
$mail->SMTPAuth=true;
$mail->SMTPSecure="ssl";
$mail->Port=465;
$mail->Username ="me@gmail.com";
$mail->Password="mypassword";
$mail->AddAddress("to@yahoo.co.in");
$mail->SetFrom("me@gmail.com", "myname");
$mail->AddReplyTo("someone@gmail.com","someone");
$mail->Subject="Greetings from ME";
$mail->Body="Greeting !! I am glad you received this message";
$mail->WordWrap=50;
if($mail->send())
{
echo "Mail sent successfully";
}
else
{
echo "Sorry mail could not be sent because of error ".$mail->ErrorInfo;
}
?>
SMTP 调试是:
CLIENT -> SERVER: EHLO messengerclick.byethost3.com 2015-07-26 12:49:42 CLIENT -> SERVER: AUTH LOGIN 2015-07-26 12:49:42
CLIENT -> SERVER: Y2hlcm9ja3oxOUBnbWFpbC5jb20= 2015-07-26 12:49:42
CLIENT -> SERVER: Y2hldGFucm9ja3MxOQ== 2015-07-26 12:49:43
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 sc16sm22415466wjb.28 - gsmtp 2015-07-26 12:49:43
SMTP Error: Could not authenticate. 2015-07-26 12:49:43
CLIENT -> SERVER: QUIT 2015-07-26 12:49:43 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Sorry mail could not be sent because of error SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
我已在我的 gmail 帐户上启用了对未知应用的访问权限。 我还单击了此链接上的继续 http://www.google.com/accounts/DisplayUnlockCaptcha 登录后。 我从我的 byethost 帐户运行它。它适用于 smtp.mail.yahoo.com
请帮助我知道我做错了什么。
【问题讨论】:
-
您是否阅读了错误消息中的链接? support.google.com/mail/answer/78754
-
是的,我做到了.. 仅在那之后对我的 gmail 帐户进行了上述更改
-
你可以尝试使用 PHPMailer 中的 xoath 分支 this - 我们需要更多的测试人员。