Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Email delivery

Nodemailer login fails because Microsoft 365 has SMTP AUTH turned off

ErrorInvalid login: 535 5.7.139 Authentication unsuccessful, SmtpClientAuthentication is disabled for the Tenant

Short answer

Microsoft 365 refused the SMTP login because authenticated SMTP (SMTP AUTH) is off for your tenant or for that mailbox. Check the mailbox setting first, since it overrides the organization setting. Then check the tenant setting and whether security defaults are on. Enabling SMTP AUTH for the sending mailbox fixes it.

  • Applies to Exchange Online, Nodemailer 6, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    In Exchange Online PowerShell, read both switches for the mailbox you send from. A blank mailbox value means it follows the organization setting.

    Connect-ExchangeOnline
    Get-CASMailbox -Identity sender@example.com | Format-List SmtpClientAuthenticationDisabled
    Get-TransportConfig | Format-List SmtpClientAuthenticationDisabled
  2. 2Match what you see, then jump to its fix

    1. 1Mailbox value is blank, organization value is TrueSMTP AUTH is turned off for the whole organizationFix
    2. 2Get-CASMailbox shows True for the senderThe mailbox itself has SMTP AUTH disabledFix
    3. 3Both properties look right, yet the 535 error staysSecurity defaults are enabled in the tenantFix

What does the error look like?

  • Invalid login: 535 5.7.139 Authentication unsuccessful, SmtpClientAuthentication is disabled for the Tenant
  • 535 5.7.139

Cause 1 of 3

SMTP AUTH is turned off for the whole organization

1Check

Microsoft recommends disabling SMTP AUTH organization-wide and enabling it only for accounts that need it, so many tenants have it off.

Get-TransportConfig | Format-List SmtpClientAuthenticationDisabled

2Fix

Leave the tenant setting off and switch SMTP AUTH on for the one sending mailbox (next cause). Turn it on for everyone only if you must.

Set-TransportConfig -SmtpClientAuthenticationDisabled $false

3Verify

The property now reads False.

Get-TransportConfig | Format-List SmtpClientAuthenticationDisabled

Confirmed by learn.microsoft.com

Did this fix it?

Cause 2 of 3

The mailbox itself has SMTP AUTH disabled

1Check

The mailbox setting takes precedence over the organization setting, so a mailbox set to True stays blocked even when the tenant allows it.

Get-CASMailbox -Identity sender@example.com | Format-List SmtpClientAuthenticationDisabled

2Fix

Enable it for that mailbox. In the admin center the same switch is Users, Active users, Mail, Manage email apps, Authenticated SMTP.

Set-CASMailbox -Identity sender@example.com -SmtpClientAuthenticationDisabled $false

3Verify

The property reads False, then send a test mail from Nodemailer.

Get-CASMailbox -Identity sender@example.com | Format-List SmtpClientAuthenticationDisabled

Confirmed by learn.microsoft.com

Did this fix it?

Cause 3 of 3

Security defaults are enabled in the tenant

1Check

When security defaults are on, SMTP AUTH is already disabled in Exchange Online. Open Microsoft Entra ID and look at the security defaults switch under properties.

# Microsoft Entra admin center: Entra ID > Overview > Properties > Manage security defaults

2Fix

To keep using SMTP AUTH you need to disable security defaults, which lowers protection for the whole tenant: Manage security defaults, set Security defaults to Disabled, Save. Microsoft says to replace them with Conditional Access policies right after. If that is not acceptable, move the app to OAuth, which SMTP AUTH supports.

# No command: the switch is in the Entra admin center (see the check above)

3Verify

After the change, send a test mail and confirm the 535 error is gone.

node send-test.js

Confirmed by learn.microsoft.com

Did this fix it?

How do I stop it coming back?

  • Enable SMTP AUTH only on dedicated sender mailboxes and keep the tenant setting off.
  • Plan a move to OAuth: Microsoft says SMTP AUTH supports modern authentication through OAuth as well as basic authentication.
  • Record the Exchange settings next to the app's deploy notes so a tenant change is easy to trace.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Email

SendGrid rejects your API key from Node.js

"message":"authorization required"

SendGrid answers 401 when the Authorization header is missing or the key is unknown, and 403 when it knows the key but refuses the action.

3 causes, each with a fix

Email

Django send_mail fails or hangs with an SSL error

smtplib.SMTPException raised from send_mail()

Django has two secure modes that must not be mixed: EMAIL_USE_TLS for explicit TLS (STARTTLS, usually port 587) and EMAIL_USE_SSL for implicit TLS (usually port 465).

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.