Nodemailer login fails because Microsoft 365 has SMTP AUTH turned off
Invalid login: 535 5.7.139 Authentication unsuccessful, SmtpClientAuthentication is disabled for the TenantShort 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.
Fix it fast
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 SmtpClientAuthenticationDisabled2Match what you see, then jump to its fix
What does the error look like?
Invalid login: 535 5.7.139 Authentication unsuccessful, SmtpClientAuthentication is disabled for the Tenant535 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 SmtpClientAuthenticationDisabled2Fix
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 $false3Verify
The property now reads False.
Get-TransportConfig | Format-List SmtpClientAuthenticationDisabledConfirmed by learn.microsoft.com
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 SmtpClientAuthenticationDisabled2Fix
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 $false3Verify
The property reads False, then send a test mail from Nodemailer.
Get-CASMailbox -Identity sender@example.com | Format-List SmtpClientAuthenticationDisabledConfirmed by learn.microsoft.com
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 defaults2Fix
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.jsConfirmed by learn.microsoft.com
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
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 fixCodeIgniter email does not send and shows no error message
$email->printDebugger() prints an empty result
CodeIgniter signals a failed email only by send() returning false, with no exception.
4 causes, each with a fixDjango 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 fixDKIM shows 'bad version' or 'unknown key type' because the DNS key record is malformed
dkim=fail (unknown key type)
These results mean the receiver found your DKIM key record but could not use it.
4 causes, each with a fixSmtpException: Unable to read data from the transport connection (net_io_connectionclosed)
System.Net.Mail.SmtpException: Unable to read data from the transport connection: net_io_connectionclosed.
The server closed the connection while SmtpClient was waiting for a reply.
4 causes, each with a fixDovecot refuses to start: Can't load SSL certificate, no valid PEM certificate
doveconf: Error: ssl enabled, but ssl_cert not set
Dovecot reads the ssl_cert setting as the file's contents, not a path, so in 2.3 the value must start with a less-than sign.
3 causes, each with a fix