NODEMAILER - 错误:缺少"PLAIN"的凭据



我有这样配置的Nodemailer:

let transporter = nodemailer.createTransport({
host: 'mail.notreforce.org',
port: 587,
secure: false, //true for 465, false for other ports
auth: {
name: env.email,
pass: env.pasword,
},
tls:{
rejectUnauthorized: false
}
});
let mailOptions = {
from: '"Nguvu yetu" <test@notreforce.org>', //sender address
to: user.email, //list of receivers
subject: "Email verification",
html: output,
};
//send mail with defined transport object
transporter.sendMail(mailOptions,error=>{
if (error){
return console.log(error);
}
res.status(200).json({msg:"Email has been sent"})
})

但我在下面得到错误

Error: Missing credentials for "PLAIN"
at SMTPConnection._formatError (C:web-projectsAngular appsTosEcommercebackendnode_modulesnodemailerlibsmtp-connectionindex.js:784:19)
at SMTPConnection.login (C:web-projectsAngular appsTosEcommercebackendnode_modulesnodemailerlibsmtp-connectionindex.js:448:38)
at C:web-projectsAngular appsTosEcommercebackendnode_modulesnodemailerlibsmtp-transportindex.js:271:32
at SMTPConnection.<anonymous> (C:web-projectsAngular appsTosEcommercebackendnode_modulesnodemailerlibsmtp-connectionindex.js:215:17)
at Object.onceWrapper (events.js:420:28)
at SMTPConnection.emit (events.js:314:20)
at SMTPConnection._actionEHLO (C:web-projectsAngular appsTosEcommercebackendnode_modulesnodemailerlibsmtp-connectionindex.js:1313:14)
at SMTPConnection._processResponse (C:web-projectsAngular appsTosEcommercebackendnode_modulesnodemailerlibsmtp-connectionindex.js:942:20)
at SMTPConnection._onData (C:web-projectsAngular appsTosEcommercebackendnode_modulesnodemailerlibsmtp-connectionindex.js:749:14)
at TLSSocket.SMTPConnection._onSocketData (C:web-projectsAngular appsTosEcommercebackendnode_modulesnodemailerlibsmtp-connectionindex.js:195:44) {
code: 'EAUTH',
command: 'API'
}

已尝试用实际值替换密钥用户通行证,但错误仍然发生。非常感谢您的帮助。

类似的代码在我的dev环境中适用,但在生产中不适用。我猜.env中的值没有被考虑在内。因此,我对userpass的值进行了硬编码,并成功了。我读到您已经测试过了,所以您可能想尝试portsecure的其他值?这些对我有用:

const transporterOVH = nodemailer.createTransport({
host: "ssl0.ovh.net",
port: 465,
secure: true, 
auth: {
user: "contact@mycompany.com",
pass: "HARDCODED_PASSWORD"
},
tls:{
ciphers:'SSLv3'
}
});

很抱歉这么不准确,我只是想分享一下在我的情况下有效的方法。祝你今天过得愉快!

最新更新