简体   繁体   English

如何通过 Nodemailer Gmail 从 Heroku 发送电子邮件?

[英]How can I send emails via Nodemailer Gmail from Heroku?

I can't use Heroku for send e-mails with Nodemailer.我不能使用 Heroku 通过 Nodemailer 发送电子邮件。 If I send a request on Localhost, it works but when I try to do this in Heroku, I got that error below.如果我在 Localhost 上发送请求,它可以工作,但是当我尝试在 Heroku 中执行此操作时,我在下面收到了该错误。


2020-07-20T15:57:12.346794+00:00 app[web.1]:     '534-5.7.14 db2zxU6IPdAWjsqy4cYGjB4Rv6dAq5CqOV8jd_fGPX8S-R0vsP-CKcCsmKYqBwCVhCdnL\n' +

2020-07-20T15:57:12.346795+00:00 app[web.1]:     '534-5.7.14 S2B1oDm_eEW0E4obWbTebMsf2BXprvCUviyFQQqVbFmhLgDFMV4qjgKjpaJaPUZ5>\n' +

2020-07-20T15:57:12.346795+00:00 app[web.1]:     '534-5.7.14 Please log in via your web browser and then try again.\n' +

2020-07-20T15:57:12.346795+00:00 app[web.1]:     '534-5.7.14  Learn more at\n' +

2020-07-20T15:57:12.346795+00:00 app[web.1]:     '534 5.7.14  https://support.google.com/mail/answer/78754 m7sm20190945qti.6 - gsmtp',

2020-07-20T15:57:12.346795+00:00 app[web.1]:   responseCode: 534,

2020-07-20T15:57:12.346796+00:00 app[web.1]:   command: 'AUTH PLAIN'

2020-07-20T15:57:12.346797+00:00 app[web.1]: }

2020-07-20T15:57:12.363186+00:00 app[web.1]: [2020-07-20 15:57:12] INFO  [XwRsbT31Bqs] Connection closed

I got that error我得到了那个错误

I'm using:我在用着:

const transporter = nodemailer.createTransport({
    host: 'https://motofrete-backend.herokuapp.com',
    service: "Gmail",
    logger: true,
});

transporter.verify(function (error, success) {
    if (error) {
        console.log(error);
    } else {
        console.log("Server is ready to take our messages", success);
    };
});

transporter.sendMail({
            from: 'Artur <marchiartur@gmail.com>',
            to: email.to,
            auth: {
                user: process.env.email,
                pass: process.env.passMail,
                refreshToken: process.env.REFRESH_TOKEN,
                accessToken: process.env.ACCESS_TOKEN,
            },

Allow less secure apps: If you don't use 2-Step Verification, you might need to allow less secure apps to access your account.允许安全性较低的应用:如果您不使用两步验证,您可能需要允许安全性较低的应用访问您的帐户。

Follow the following url to read instructions on how to do that.按照以下 url 阅读有关如何执行此操作的说明。

https://support.google.com/mail/answer/7126229?visit_id=637308585317776650-2698520165&rd=2#cantsignin https://support.google.com/mail/answer/7126229?visit_id=637308585317776650-2698520165&rd=2#cantsignin

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

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