无法在 nodejs 中使用 office365 帐户从 nodemailer 发送电子邮件,出现错误身份验证失败? [英] Not able to send emails from nodemailer with office365 account in nodejs getting error Authentication unsuccessful?
本文介绍了无法在 nodejs 中使用 office365 帐户从 nodemailer 发送电子邮件,出现错误身份验证失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 nodemailer 向具有 Office 365 帐户电子邮件和密码的用户发送电子邮件,但每次我都收到错误消息 - 身份验证失败
I am using nodemailer to send emails to user with office 365 account email and password are all correct but every time i am getting error - Authentication unsuccessful
Error: Invalid login:Authentication unsuccessful[BL0PR01CA0033.prod.exchangelabs.com]
code: 'EAUTH',
response: '535 5.7.3 Authentication unsuccessful [BL0PR01CA0033.prod.exchangelabs.com]',
response Code: 535,
command: 'AUTH LOGIN'**
推荐答案
您必须在管理设置中为 O365 邮箱或用户启用 SMTP 登录
You have to enable SMTP login for the O365 mail box or user in the admin settings
转到邮件设置
开启经过身份验证的 SMTP
Turn On Authenticated SMTP
完成后使用
var transport = nodemailer.createTransport({
service: "Outlook365",
auth: {
user: 'O365email',
pass: 'O365password'
},
});
var mailOptions = {
from: 'o365email',
to: 'exaple@gmail.com', // list of receivers
subject: "Password reset requested for your account", // Subject line
text: 'reset password',
html: "<h1>Mail Testing</h1>" // html body
};
transport.sendMail(mailOptions, function(error, response){
if(error){
resp.status(500);
resp.send(error);
}else{
resp.send({message:'done'});
}
});
这篇关于无法在 nodejs 中使用 office365 帐户从 nodemailer 发送电子邮件,出现错误身份验证失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文