Unable to authenticate outlook address via nodemailer

10,171

Solution 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.

Solution 2

You have to enable Authenticated SMTP Email app for the O365 user

Check this answer

Solution 3

You must enable SMTP login for the O365 mailbox or user in the admin settings

If the user has multifactor turned on, then you need to use "app password", normal password won't work if MFA is enabled.

You need to disable security defaults or adjust Conditional Access policies.

Check this answer

Solution 4

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.

Share:
10,171

Related videos on Youtube

dlucci
Author by

dlucci

Updated on June 04, 2022

Comments

  • dlucci
    dlucci over 1 year

    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: '[email protected]',
    to: '[email protected]',
    subject: 'Hello',
    text: 'Test 1235'
    }
    transporter.sendMail(data, (err, info)=> {
    if(err)
      console.log(err)
    else
      console.log(info)
    })
    })'
    
  • dlucci
    dlucci over 5 years
    I ended up using a gmail account instead of an outlook account and that solution worked swimingly
  • Beeno Tung
    Beeno Tung over 5 years
    using gmail, you will have limited number of account per phone number
  • dlucci
    dlucci over 5 years
    it's only sending an email to one account. how is a phone number a limiting factor in this case?
  • Beeno Tung
    Beeno Tung over 5 years
    I assume you're doing the email interaction for a project, and it's better to use different email for different projects, expecially when the projects are under different team. When using google account with personal phone number, you'll run out of the quota one day, if you're doing many projects from time to time.
  • dlucci
    dlucci over 5 years
    It is an email specifically for this project and not someone's email. What I am using this feature for will only be used for this one case and that's it.