Unable to authenticate outlook address via nodemailer

这一生的挚爱 提交于 2020-06-03 22:08:19

问题


I am trying to authenticate an outlook email account using nodemailer. But, I continuously get the same message:

{ Error: Invalid login: 535 5.7.3 Authentication unsuccessful [CY1PR03CA0041.namprd03.prod.outlook.com] at SMTPConnection._formatError (/user_code/node_modules/nodemailer/lib/smtp-connection/index.js:591:19) at SMTPConnection._actionAUTHComplete (/user_code/node_modules/nodemailer/lib/smtp-connection/index.js:1320:34) at SMTPConnection._responseActions.push.str (/user_code/node_modules/nodemailer/lib/smtp-connection/index.js:1278:18) at SMTPConnection._processResponse (/user_code/node_modules/nodemailer/lib/smtp-connection/index.js:747:20) at SMTPConnection._onData (/user_code/node_modules/nodemailer/lib/smtp-connection/index.js:543:14) at TLSSocket._socket.on.chunk (/user_code/node_modules/nodemailer/lib/smtp-connection/index.js:694:51) at emitOne (events.js:96:13) at TLSSocket.emit (events.js:188:7) at readableAddChunk (_stream_readable.js:176:18) at TLSSocket.Readable.push (_stream_readable.js:134:10) code: 'EAUTH', response: '535 5.7.3 Authentication unsuccessful [CY1PR03CA0041.namprd03.prod.outlook.com]', responseCode: 535, command: 'AUTH LOGIN' }

Here is my code for nodemailer:

const functions = require('firebase-functions');
var nodemailer=require('nodemailer')

var transporter = nodemailer.createTransport("SMTP", {
auth: {
  user: 'username',
  pass: 'password'
},
service: "hotmail"

exports.sendMail 
=functions.database.ref('requestedChats').onWrite((event)=>{
const data = {
from: 'username@outlook.com',
to: 'mytest@gmail.com',
subject: 'Hello',
text: 'Test 1235'
}
transporter.sendMail(data, (err, info)=> {
if(err)
  console.log(err)
else
  console.log(info)
})
})'

回答1:


I had this issue sometime. Check the outlook account, see if the mail service provider sent you an email to enable remote login.

Login attempt are rejected when you're trying to login from a new server (seems to be IP-based checking). Once you manually approve the login attempt, that server will be 'whitelisted'.

Also check for the subject (email title). It should be plain text and should not consist html code.

If you still have this issue or don't received any email from the mail service provider, this is a real issue and better off contact the mail service provider for support.




回答2:


I had the same problem and the issue was this:

I was using credentials provided by my hosting provider. The default setting was that the credentials were secured with GEO security, meaning the credentials wouldn't work outside my country. I was deploying on Heroku whose servers are abroad. That's why I could send emails from localhost but not from deployed app.

After I disabled the GEO security everything worked as it should.



来源:https://stackoverflow.com/questions/48732535/unable-to-authenticate-outlook-address-via-nodemailer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!