Error: Invalid login: 535-5.7.8 Username and Password not accepted

孤街醉人 提交于 2020-04-16 04:07:47

问题


The code below is perfect to send emails using node.js code/program. However, still getting error mentioned in the title.

var nodemailer = require('nodemailer');

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

var mailOptions = {
  from: 'haideryaqoobengr@gmail.com',
  to: 'haideryaqoob720@gmail.com',
  subject: 'Sending Email using Node.js',
  text: 'That was easy!'
};

transporter.sendMail(mailOptions, function(error, info){
  if (error) {
    console.log(error);
  } else {
    console.log('Email sent: ' + info.response);
  }
});

回答1:


Yes, code is perfect. However, you need to allow less secure apps from your google account to send emails. Through this link. Allow less secure apps From your Google Account



来源:https://stackoverflow.com/questions/59188483/error-invalid-login-535-5-7-8-username-and-password-not-accepted

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!