node.js 电子邮件不会通过 gmail smtp 发送 [英] node.js email doesn't get sent with gmail smtp

查看:41
本文介绍了node.js 电子邮件不会通过 gmail smtp 发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试发送电子邮件 gmail smtp,但我收到了错误:

I'm trying to send the email gmail smtp but I'm getting the error:

我的邮箱和密码正确我正在使用nodemailer发送邮件;

My email and password is correct I'm using the nodemailer for sending the mail;

       var nodemailer = require('nodemailer');

                // create reusable transporter object using SMTP transport 
                var transporter = nodemailer.createTransport({
                    service: 'Gmail',
                    auth: {
                        admin: 'myuseremail.com',
                        pass: 'password'
                    }
                });

                var mailOptions = {
                    from: 'sender address', // sender address 
                    to: to, // list of receivers 
                    subject: 'Password Reset', // Subject line 
                    html: 'Your one time password is : <b>' + temporaryPassword + ' </b>' // html body 
                };

                transporter.sendMail(mailOptions, function (error, info) {
                    console.log(error,info);
              }

在日志中我收到错误:

    {
     [Error: Invalid login]
      code: 'EAUTH',
      response: '535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8  https://support.google.com/mail/answer/14257 k5sm20957041pdo.48 - gsmtp',
      responseCode: 535
    } 

我尝试了一些链接,但不起作用:
https://laracasts.com/discuss/channels/general-discussion/help-email-doesnt-get-sent-with-gmail-smtp

I try some link but that doesn't work:
https://laracasts.com/discuss/channels/general-discussion/help-email-doesnt-get-sent-with-gmail-smtp

推荐答案

var transporter = nodemailer.createTransport({
  service: 'Gmail',
  auth: {
    user: 'user@gmail.com',
    pass: 'password'
  }
});

尝试上述方法,然后执行以下对我有用的操作.

Try the above, and do the following which worked for me.

登录 https://www.google.com/settings/security/lesssecureapps开启访问不太安全的应用程序.

Login to https://www.google.com/settings/security/lesssecureapps and TURN ON Access for less secure apps.

我希望它也对你有用.

谢谢.

这篇关于node.js 电子邮件不会通过 gmail smtp 发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆