Gmail SMTP 阻止真实服务器而不是本地主机
Gmail SMTP blocking real server not localhost
我已经按照以下方式为我的 wordpress 站点配置了 phpmailer:
<?php
add_action( 'phpmailer_init', 'setup_smtp');
function setup_smtp( $phpmailer ) {
if ( ! is_object( $phpmailer ) ) {
$phpmailer = (object) $phpmailer;
}
$phpmailer->Mailer = 'smtp';
$phpmailer->Host = 'smtp.gmail.com';
$phpmailer->SMTPAuth = true;
$phpmailer->Port = '465';
$phpmailer->Username = 'duet383@gmail.com';
$phpmailer->Password = 'xxxxxxxx';
$phpmailer->SMTPSecure = 'ssl';
$phpmailer->From = 'duet383@gmail.com';
$phpmailer->FromName = 'Asian Restaurant';
$phpmailer->SMTPDebug = 2;
}
它在本地主机上发送电子邮件,但在真实服务器上时出现以下错误:
2021-05-05 17:28:55 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP 26sm5525488qtd.73 - gsmtp
2021-05-05 17:28:55 CLIENT -> SERVER: EHLO miraj94.000webhostapp.com
2021-05-05 17:28:55 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [2a02:4780:bad:3:fced:1ff:fe03:76]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
2021-05-05 17:28:55 CLIENT -> SERVER: AUTH LOGIN
2021-05-05 17:28:55 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2021-05-05 17:28:55 CLIENT -> SERVER: [credentials hidden]
2021-05-05 17:28:55 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2021-05-05 17:28:55 CLIENT -> SERVER: [credentials hidden]
2021-05-05 17:28:56 SERVER -> CLIENT: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbu534-5.7.14 mBCp0KPnA6lLVDXtO3PD4WNqyB_meMsjJFlkSNZ9vC63f-RVlCMCuQTTtGyTG_O-Udkkr534-5.7.14 ll7IKMM31GmIn6raNGiiVq6cQEREBB9fClbMYCyhqBphXb93cJjmcAqwJXJw0QxJ>534-5.7.14 Please log in via your web browser and then try again.534-5.7.14 Learn more at534 5.7.14 https://support.google.com/mail/answer/78754 26sm5525488qtd.73 - gsmtp
2021-05-05 17:28:56 SMTP ERROR: Password command failed: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbu534-5.7.14 mBCp0KPnA6lLVDXtO3PD4WNqyB_meMsjJFlkSNZ9vC63f-RVlCMCuQTTtGyTG_O-Udkkr534-5.7.14 ll7IKMM31GmIn6raNGiiVq6cQEREBB9fClbMYCyhqBphXb93cJjmcAqwJXJw0QxJ>534-5.7.14 Please log in via your web browser and then try again.534-5.7.14 Learn more at534 5.7.14 https://support.google.com/mail/answer/78754 26sm5525488qtd.73 - gsmtp
SMTP Error: Could not authenticate.
2021-05-05 17:28:56 CLIENT -> SERVER: QUIT
2021-05-05 17:28:56 SERVER -> CLIENT: 221 2.0.0 closing connection 26sm5525488qtd.73 - gsmtp
SMTP Error: Could not authenticate.
我在 000webhost.com 上使用免费虚拟主机和域,我的网站地址是 https://miraj94.000webhostapp.com
免费计划不支持电子邮件帐户。
https://www.000webhost.com/
如果您想从您的网站发送电子邮件,请更改您的主机或升级到付费计划
经过长时间的研究,我找到了解决方案。
- 登录我的 Gmail 帐户
- 转到https://accounts.google.com/b/0/DisplayUnlockCaptcha
- 点击继续按钮
[已启用安全性较低的应用程序访问]
另外 this Whosebug answer 可能有帮助。
我已经按照以下方式为我的 wordpress 站点配置了 phpmailer:
<?php
add_action( 'phpmailer_init', 'setup_smtp');
function setup_smtp( $phpmailer ) {
if ( ! is_object( $phpmailer ) ) {
$phpmailer = (object) $phpmailer;
}
$phpmailer->Mailer = 'smtp';
$phpmailer->Host = 'smtp.gmail.com';
$phpmailer->SMTPAuth = true;
$phpmailer->Port = '465';
$phpmailer->Username = 'duet383@gmail.com';
$phpmailer->Password = 'xxxxxxxx';
$phpmailer->SMTPSecure = 'ssl';
$phpmailer->From = 'duet383@gmail.com';
$phpmailer->FromName = 'Asian Restaurant';
$phpmailer->SMTPDebug = 2;
}
它在本地主机上发送电子邮件,但在真实服务器上时出现以下错误:
2021-05-05 17:28:55 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP 26sm5525488qtd.73 - gsmtp
2021-05-05 17:28:55 CLIENT -> SERVER: EHLO miraj94.000webhostapp.com
2021-05-05 17:28:55 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [2a02:4780:bad:3:fced:1ff:fe03:76]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
2021-05-05 17:28:55 CLIENT -> SERVER: AUTH LOGIN
2021-05-05 17:28:55 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2021-05-05 17:28:55 CLIENT -> SERVER: [credentials hidden]
2021-05-05 17:28:55 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2021-05-05 17:28:55 CLIENT -> SERVER: [credentials hidden]
2021-05-05 17:28:56 SERVER -> CLIENT: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbu534-5.7.14 mBCp0KPnA6lLVDXtO3PD4WNqyB_meMsjJFlkSNZ9vC63f-RVlCMCuQTTtGyTG_O-Udkkr534-5.7.14 ll7IKMM31GmIn6raNGiiVq6cQEREBB9fClbMYCyhqBphXb93cJjmcAqwJXJw0QxJ>534-5.7.14 Please log in via your web browser and then try again.534-5.7.14 Learn more at534 5.7.14 https://support.google.com/mail/answer/78754 26sm5525488qtd.73 - gsmtp
2021-05-05 17:28:56 SMTP ERROR: Password command failed: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbu534-5.7.14 mBCp0KPnA6lLVDXtO3PD4WNqyB_meMsjJFlkSNZ9vC63f-RVlCMCuQTTtGyTG_O-Udkkr534-5.7.14 ll7IKMM31GmIn6raNGiiVq6cQEREBB9fClbMYCyhqBphXb93cJjmcAqwJXJw0QxJ>534-5.7.14 Please log in via your web browser and then try again.534-5.7.14 Learn more at534 5.7.14 https://support.google.com/mail/answer/78754 26sm5525488qtd.73 - gsmtp
SMTP Error: Could not authenticate.
2021-05-05 17:28:56 CLIENT -> SERVER: QUIT
2021-05-05 17:28:56 SERVER -> CLIENT: 221 2.0.0 closing connection 26sm5525488qtd.73 - gsmtp
SMTP Error: Could not authenticate.
我在 000webhost.com 上使用免费虚拟主机和域,我的网站地址是 https://miraj94.000webhostapp.com
免费计划不支持电子邮件帐户。
https://www.000webhost.com/
如果您想从您的网站发送电子邮件,请更改您的主机或升级到付费计划
经过长时间的研究,我找到了解决方案。
- 登录我的 Gmail 帐户
- 转到https://accounts.google.com/b/0/DisplayUnlockCaptcha
- 点击继续按钮
[已启用安全性较低的应用程序访问]
另外 this Whosebug answer 可能有帮助。