node.js nodemailer gmail error

你离开我真会死。 提交于 2019-11-30 12:12:33

Try installing nodemailer-smtp-transport and then use it inside your createTransport function.

var smtpTransport = require('nodemailer-smtp-transport');

var transport = nodemailer.createTransport(smtpTransport({
    service: 'gmail',
    auth: {
        user: 'myemail@gmail.com', // my mail
        pass: 'mypassword'
    }
}));

And try also while in your google account enabling this: https://www.google.com/settings/security/lesssecureapps

I really think this should be your auth problem

it's works with me after using none-secure port

var transporter = nodemailer.createTransport({
  host: 'smtp.gmail.com',
  port: 587,
  secure: false, // secure:true for port 465, secure:false for port 587
  auth: {
    user: 'xxxx@gmail.com',
    pass: 'xxxx'
  }
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!