I´m facing an authentication problem with outlook365. I have checked the credentials several times and it is ok.
I always get this error:
code: 'EAUTH', response: '535 5.7.3 Authentication unsuccessful [CP2P152CA0028.LAMP152.PROD.OUTLOOK.COM]', responseCode: 535, command: 'AUTH LOGIN'
That's the code I'm using:
const transporter = nodemailer.createTransport({
service: "Outlook365", // Office 365 server
auth: {
user: 'email@email.com.br',
pass: 'appPassword'
},
});
var data = new Date();
const mailOptions = {
from: 'email@email.com.br',
to: email_input,
subject: 'E-mail Automático para Redefinição de Senha',
html: "<h1>Olá, " + nome + "!</h1> Recebemos uma solicitação para redefinir a senha de sua conta no SARR. Aqui está seu código para criar uma nova senha:<br><br><h2 align='center'>" + codigo + "</h2><br>Quando isto ocorreu: <br>" + data + "."
};
transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
res.render('set_password.ejs', { message: 'Algo deu errado, tente novamente mais tarde'});
} else {
console.log('Email enviado: ' + info.response);
// render the page and pass in any flash data if it exists
res.render('codigo_reseta_senha.ejs', { message: req.flash('cod_fail'),email: email_input});
}
});
I've suspected that the problem is related to a two step authentication, so I created an app password, from outlook configuration, but the problem persists. I´ve searched along the foruns, but none could help. Does anyone has a clue about what I´m doing wrong?