I have an Azure Ubuntu 18.04 server with Node v12.13.1, my local machine is Windows 10 and node v10.16.0.
When I run on my local computer there is no issue with Nodemailer sending the email, it sends and quickly appears in my email.
However when it is run on my Azure server, I get the following error.
Error: Invalid login: 535 5.7.3 Authentication unsuccessful [BY5PR16CA0034.nampr d16.prod.outlook.com]
at SMTPConnection._formatError (/home/user/EMR/node_modules/nodemailer/l ib/smtp-connection/index.js:784:19)
at SMTPConnection._actionAUTHComplete (/home/user/EMR/node_modules/nodem ailer/lib/smtp-connection/index.js:1523:34)
at SMTPConnection.<anonymous> (/home/user/EMR/node_modules/nodemailer/li b/smtp-connection/index.js:1481:18)
at SMTPConnection._processResponse (/home/user/EMR/node_modules/nodemail er/lib/smtp-connection/index.js:942:20)
at SMTPConnection._onData (/home/user/EMR/node_modules/nodemailer/lib/sm tp-connection/index.js:749:14)
at TLSSocket.SMTPConnection._onSocketData (/home/user/EMR/node_modules/n odemailer/lib/smtp-connection/index.js:195:44)
at TLSSocket.emit (events.js:210:5)
at addChunk (_stream_readable.js:309:12)
at readableAddChunk (_stream_readable.js:290:11)
at TLSSocket.Readable.push (_stream_readable.js:224:10) {
code: 'EAUTH',
response: '535 5.7.3 Authentication unsuccessful [BY5PR16CA0034.namprd16.prod. outlook.com]',
responseCode: 535,
command: 'AUTH LOGIN'
}
Here is the code for running Nodemailer on my node.js server:
let transport = nodemailer.createTransport({
service: "Outlook365",
auth: {
user: process.env.USER,
pass: process.env.PASS
},
tls:{
rejectUnauthorized: false
}
})
let message = {
from: '"Name Apps" <nameapps@name.org>',
to: item.email,
subject: subjectText,
html: `<b>HTML message</b>`
};
transport.sendMail(message, function(err, info) {
if (err) {
console.log(err)
} else {
console.log(info);
}
});