【发布时间】:2017-11-04 20:21:57
【问题描述】:
我在使用 Google SMTP 和最新版本的 PHPMailer 发送邮件时遇到问题。这里有很多问题,但答案对我不起作用。
我正在使用带有免费子域000webhost 的免费托管。
这是我从 PHPMailer docs 发送电子邮件的标准 PHP 代码:
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'GMAIL EMAIL ACCOUNT';
$mail->Password = 'MY PASSWORD FOR GMAIL EMAIL ACCOUNT';
$mail->SMTPSecure = 'tlc';
$mail->Port = 587;
$mail->SMTPDebug = 3;
$mail->setFrom('EMAIL ADDRESS', 'EXAMPLE');
$mail->addAddress('ADDRESS TO SEND', 'From contact form');
$mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com');
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
我得到这个错误:
.... 2017-06-03 15:15:33 服务器 -> 客户端:535-5.7.8 用户名和密码不被接受。了解更多信息 535 5.7.8 https://support.google.com/mail/?p=BadCredentials 203sm11822739ywk.62 - gsmtp 2017-06-03 15:15:33 SMTP 错误:密码命令失败:535-5.7.8 用户名和密码不被接受。了解更多信息 535 5.7.8 https://support.google.com/mail/?p=BadCredentials 203sm11822739ywk.62 - gsmtp 2017-06-03 15:15:33 SMTP 错误:无法验证。 .....
如果我将ssl 与端口465 一起使用,我会看到同样的错误。
在我的Gmail 电子邮件帐户中,2 工厂身份验证是 OFF,Allow less secure apps 是 ON。
我真的不知道该怎么办。
【问题讨论】:
-
没有
tlcforSMTPSecure这样的设置。