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'**
You have to enable SMTP login for the O365 mail box or user in the admin settings
Go to Mail Settings
Turn On Authenticated SMTP
once that is done use
var transport = nodemailer.createTransport({
service: "Outlook365",
auth: {
user: 'O365email',
pass: 'O365password'
},
});
var mailOptions = {
from: 'o365email',
to: '[email protected]', // 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'});
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With