Nodejs nodemailer错误

时间:2018-02-27 10:50:55

标签: javascript node.js nodemailer

运行Nodemailer会导致以下错误,那么我应该怎么做才能解决它?

  

错误:缺少“PLAIN”的凭据       在SMTPConnection._formatError

var nodemailer=require('nodemailer');
var transporter = nodemailer.createTransport({
    service:'Gmail',
    auth:{
        user:'kumaresankeerthy@gmail.com',
        password:'9943886854**'
    }
});
var mailOptions={

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

3 个答案:

答案 0 :(得分:1)

您在构造函数中提供了错误的参数。其password而非let transporter = nodemailer.createTransport({ host: 'smtp.ethereal.email', port: 587, secure: false, // true for 465, false for other ports auth: { user: account.user, // generated ethereal user pass: account.pass // generated ethereal password } });

根据official docs

<div>{{ place.place2.name }}</div>

答案 1 :(得分:0)

您需要使用真实Google帐户的实际电子邮件和密码以不同方式设置传输器。

// create reusable transporter object using the default SMTP transport
let transporter = nodemailer.createTransport({
    service: 'gmail',
    auth: {
        user: 'somerealemailaddress@gmail.com', //email address to send from
        pass: 'somerealemailpassword' //the actual password for that account
    }
});

答案 2 :(得分:0)

  • 通过转到以下网址解决了这个问题(使用我要发送邮件的帐户连接到谷歌时):

https://www.google.com/settings/security/lesssecureapps * 之后你会在你的Gmail中启用安全性较低的应用程序;工作