Jak*_*son 2 gmail smtp node.js nodemailer
我正在尝试使用带有 Gmail 帐户的 Nodemailer 在我的应用程序中设置电子邮件验证。
我的问题是它报告错误,指出我的用户名和密码尚未被接受:
There was an error: Error: Invalid login: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/?p=BadCredentials a3sm2007362wri.89 - gsmtp
Run Code Online (Sandbox Code Playgroud)
const transporter = nodemailer.createTransport({
host: "smtp.gmail.com",
service: "Gmail",
port: 465,
secure: true,
auth: {
user: process.env.USER,
pass: process.env.PASS,
},
});
transporter.sendMail(
{
from: process.env.USER,
to: email,
subject: subject,
text: text,
},
(error) => {
if (error) {
return console.log("There was an error: " + error);
}
console.log("Email sent successfully");
}
);
Run Code Online (Sandbox Code Playgroud)
我可以确认 和process.env.USER是process.env.PASS正确的,并且我还允许不太安全的应用程序。
有什么我遗漏/不理解的吗?
“从 2022 年 5 月 30 日起,\xe2\x80\x8b\xe2\x80\x8bGoogle 不再支持使用要求您仅使用用户名和密码登录 Google 帐户的第三方应用或设备。”\ n https://support.google.com/accounts/answer/6010255?hl=en
\n解决方案
\n| 归档时间: |
|
| 查看次数: |
4467 次 |
| 最近记录: |