1

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?

Lelio Faieta
  • 6,457
  • 7
  • 40
  • 74
  • you might need the `host` name, as in the Outlook hosting name. Have you looked into it, or do you need me to point you in the right direction? – Gianluca May 18 '21 at 12:30
  • @Gianluca, thanks for your reply. I've tried first with host and port definition, but I coulnd't get it into work. I used 'smtp.office365.com' for the host. I changed to the service definition because the nodemailer documentation says this is a "well-kown" service. – Rafael Mattos May 18 '21 at 17:27
  • @GrafiCode, thanks for your reply, I gonna try the portal.azure.com configuration from the link you sent and I'll report any update – Rafael Mattos May 18 '21 at 17:28
  • @RafaelMattos are you using go daddy for your mailing service set up or no? – Gianluca May 18 '21 at 17:35
  • @Gianluca we are hosted on microsoft – Rafael Mattos May 18 '21 at 17:56
  • 1
    We changed the configs as said in the GrafiCode's link, and worked! Thanks! – Rafael Mattos May 19 '21 at 13:32

0 Answers0