【发布时间】:2020-05-14 09:36:35
【问题描述】:
我如何在 phpmailer 中使用我的电子邮件,例如 example@domain.ph。因为即使我有正确的凭据,我也总是出错。
2020-05-14 09:21:24 服务器 -> 客户端:220 smtp.gmail.com ESMTP e13sm1851788pfh.19 - gsmtp
2020-05-14 09:21:24 客户端 -> 服务器:EHLO 本地主机
2020-05-14 09:21:24 服务器 -> 客户端:250-smtp.gmail.com 为您服务,[114.108.210.106]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250DANCESTATE-- PIPELINING250-CHUNKING250 SMTPUTF8
2020-05-14 09:21:25 客户端 -> 服务器:授权登录
2020-05-14 09:21:25 服务器 -> 客户端:334 VXNlcm5hbWU6
2020-05-14 09:21:25 客户端 -> 服务器:[凭据隐藏]
2020-05-14 09:21:25 服务器 -> 客户端:334 UGFzc3dvcmQ6
2020-05-14 09:21:25 客户端 -> 服务器:[凭据隐藏]
2020-05-14 09:21:25 服务器 -> 客户端:535-5.7.8 用户名和密码不被接受。了解更多 at535 5.7.8 https://support.google.com/mail/?p=BadCredentials e13sm1851788pfh.19 - gsmtp
2020-05-14 09:21:25 SMTP 错误:密码命令失败:535-5.7.8 用户名和密码不被接受。了解更多 at535 5.7.8 https://support.google.com/mail/?p=BadCredentialse13sm1851788pfh.19 - gsmtp
SMTP 错误:无法验证。
2020-05-14 09:21:25 客户端 -> 服务器:退出
2020-05-14 09:21:25 服务器 -> 客户端:221 2.0.0 关闭连接 e13sm1851788pfh.19 - gsmtp
SMTP 错误:无法进行身份验证。
这是我的配置:
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->SMTPAutoTLS = true;
$mail->Username = 'example@domain.ph';
$mail->Password = '';
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = 587;
【问题讨论】:
-
您的域是否设置为使用 gmail 发送电子邮件?
-
@Synchro 我的电子邮件域是在 GSuite 中设置的。
-
在这种情况下,请查看the PHPMailer troubleshooting guide 中涵盖的 gmail 身份验证问题。