简体   繁体   English

如何使用nodemailer和gmail发送电子邮件?

[英]How to send email using nodemailer and gmail?

I am using nodemailer in order to send email to customers. 我正在使用nodemailer以便向客户发送电子邮件。

Here how I configured my transporter : 这是我如何配置运输机:

const mailTransport = nodemailer.createTransport({
service:'Gmail',
auth: {
    user : "xxxx",
    pass : "xxxx",
});

Unfortunately it doesn't work and I got "Invalid Login error". 不幸的是,它不起作用,并且出现“无效的登录错误”。 I checked on the web and autorized "less security connections" through settings account. 我在网上检查并通过设置帐户授予“较少的安全连接”权限。

Unfortunately I stuck with the same error... 不幸的是我坚持同样的错误...

Could explain me how can I do that ? 可以解释一下我该怎么做?

Thanks 谢谢

It is recommended to generate an app password for GMail, and use this with Nodemailer. 建议为GMail生成一个应用程序密码 ,并将其与Nodemailer一起使用。

This will bypass any 2FA dialogs and any 'sign in authorizations' you may get when using your standard password. 这将绕过使用标准密码时可能会出现的所有2FA对话框和任何“登录授权”。

See 'using Gmail' in the Nodemailer docs. 请参阅Nodemailer文档中的“使用Gmail”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM