Nodemailer with 535 5.7.3 Authentication unsuccessful

Hi I had a small web app. send the email through the form . I use smtp

const transporter = nodemailer.createTransport({
host: ‘smtp-mail.outlook.com’,
port: 587,
auth: {
user: process.env.EMAIL,
pass: process.env.PASS,
}
});

during the build process the system : it will give me the : Error: Invalid login: 535 5.7.3 Authentication unsuccessful [CH2PR04CA0014.namprd04.prod.outlook.com]…

even it is correct , I test it locally and even employed on from Heroku and worked
any ideas how to fix this ?
chao

Hey @chaowow

Have you set the EMAIL and PASS environment variables in the UI?

Yes I tried some different ways even the ones no secure at all. .Still not working

Chao

from mobile

Different ways for/of what?

You have set the environment variables as per the example below?

I’m not sure why this would happen during build as functions only run when invoked (as I understand.)

Can you share the repository you are deploying?

Yes

that’s exactly what I did .

By the different way I meant : I directly changed the user and pass as they are , just to test.

I made a simple one repo just to test : GitHub - cz101/nodemailer: A simple mailer test for third party smtp
Netlify site : brave-mirzakhani-44b160

Chao

Perhaps try the answer offered here

1 Like

Hi Coelmay

thanks for looking into it, It didn’t work based on their suggestions , which is 2016 . I’m not convinced that it is on outlook smtp server , otherwise heroku and my local PC wont work , I use the same code.

could it be firewall on netlify has more restrictions on those kinda
requests ?
Chao

There is no such firewall or blocking of requests that I am aware of. I have Nodemailer running (not using Outlook) and have no issues.

Searching for Error: Invalid login: 535 5.7.3 Authentication unsuccessful (see results) I found:

Have you tried logging out the username/password when the function runs to see the values are correct e.g.

console.log(process.env.EMAIL);
console.log(process.env.PASS);
1 Like

HI Coel

It worked this time , not sure what changed . I console log the info (it was correct and comment it out , also works , )

10:46:06 PM: [nodemon] watching extensions: js,mjs,json
10:46:06 PM: [nodemon] starting node server.js
10:46:06 PM: ========info=====
10:46:08 PM: connected to DB
10:46:10 PM: Live/Outlook Server is ready

but another problem, the deploy are still in progress , which should be finished . did I miss some setting config in netlify?

Thanks for the previous effort
Chao

You’re trying to run an instance of node judging by this command. This isn’t something you can do with Netlify.

1 Like

Got it .

Thanks for everything btw!
:slight_smile:

1 Like