Why an app, script or scanner sending through smtp.office365.com gets 535 5.7.139 Authentication unsuccessful, and how to check security defaults, SMTP AUTH settings, authentication policies, Conditional Access and the move to OAuth.
Home › Guides › Exchange Online 535 5.7.139
Last updated 18 November 2026
535 5.7.139 is Exchange Online refusing the SMTP AUTH command. Microsoft's documented wording points at the tenant's configuration, not the password:
535 5.7.139 Authentication unsuccessful, the organization configuration doesn't allow this authentication request.
It is an SMTP reply during the session (RFC 4954 defines 535 as the reply to a failed AUTH), so you normally see it in the device or application log rather than in a bounce message. Check, in this order:
SmtpClientAuthenticationDisabled).AllowBasicAuthSmtp).Each of those blocks Basic authentication (username and password). The long-term fix is to move the app to OAuth or to a connector-based method, below.
Microsoft's Learn pages quote only the first text below. The others are what admins report seeing on Microsoft Q&A; Microsoft doesn't publish a reference for them, so the "check first" column follows the setting each text names.
| Text after 535 5.7.139 Authentication unsuccessful | Check first |
|---|---|
| the organization configuration doesn't allow this authentication request (documented) | Security defaults, then authentication policies (the steps Microsoft gives for this text in its High Volume Email troubleshooting article). |
| SmtpClientAuthentication is disabled for the Tenant | The organization setting Set-TransportConfig -SmtpClientAuthenticationDisabled, and the mailbox override. |
| SmtpClientAuthentication is disabled for the Mailbox. Visit aka.ms/smtp_auth_disabled for more info. | The mailbox setting Set-CASMailbox -SmtpClientAuthenticationDisabled. The aka.ms link redirects to Microsoft's SMTP AUTH article. |
| user is locked by your organization's security defaults policy. Contact your administrator | Security defaults. |
| basic authentication is disabled | Authentication policies, security defaults and Conditional Access. |
| the request did not meet the criteria to be authenticated successfully | Not documented. Work through every check below, starting with Conditional Access and the Entra sign-in logs. |
Related codes you may see on the same connection:
| Code | Meaning (Microsoft Learn) |
|---|---|
535 5.7.3 Authentication unsuccessful | Shown in Microsoft's OAuth article as the reply to a failed XOAUTH2 sign-in, and listed with 5.7.139 in the High Volume Email troubleshooting steps. |
5.7.57 Client not authenticated to send mail | The device didn't sign in, or the sign-in failed. See the 5.7.57 guide. |
5.7.60 SMTP; Client doesn't have permissions to send as this sender | Sign-in worked, but the From address is a different mailbox without Send As permission. |
535 5.7.127, 535 5.7.142 to 535 5.7.144 | High Volume Email only: generic authentication failure, and XOAUTH2 token expiring, expired or with invalid API permissions. |
Microsoft says: "If security defaults is enabled in your organization, SMTP AUTH is already disabled in Exchange Online. To use SMTP AUTH, you need to disable security defaults." Security defaults block every authentication request made by an older protocol, and Microsoft lists "any client that uses older mail protocols such as IMAP, SMTP, or POP3" as legacy authentication.
To see the setting: Microsoft Entra admin center (at least Conditional Access Administrator), Entra ID > Overview > Properties > Manage security defaults. Turning security defaults off removes MFA and the legacy-auth block for everyone, not just the scanner. Microsoft says organizations that disable security defaults should immediately enable Conditional Access policies to keep the same protections (Microsoft-managed policies cover blocking legacy authentication and requiring MFA). Only do this if you are replacing security defaults with Conditional Access, and prefer the OAuth or connector options below.
Get-TransportConfig | Format-List SmtpClientAuthenticationDisabled Get-CASMailbox -Identity scanner@contoso.com | Format-List SmtpClientAuthenticationDisabled Set-CASMailbox -Identity scanner@contoso.com -SmtpClientAuthenticationDisabled $false
On the mailbox, $false enables SMTP AUTH, $true disables it and blank ($null, the default) follows the organization setting; the mailbox setting takes precedence. Microsoft recommends keeping SMTP AUTH off for the organization and enabling it only on the mailboxes that need it. In the Microsoft 365 admin center it is Users > Active users > user > Mail > Manage email apps > Authenticated SMTP. Microsoft also notes SMTP AUTH is disabled for organizations created after January 2020. The 5.7.57 guide has the full table and the device settings.
Microsoft: "If your authentication policy disables basic authentication for SMTP, clients cannot use the SMTP AUTH protocol even if you enable the settings outlined in this article." Authentication policies are assigned per user, or as the organization default, and a new policy created without naming any protocols blocks Basic authentication for all of them.
# Is there an organization default policy? Get-OrganizationConfig | Format-Table DefaultAuthenticationPolicy # Which policies exist, and what do they allow? Get-AuthenticationPolicy | Format-Table Name -Auto Get-AuthenticationPolicy -Identity "Block Basic Auth" # Allow Basic auth for SMTP in that policy (only if you must) Set-AuthenticationPolicy -Identity "Block Basic Auth" -AllowBasicAuthSmtp # Policy changes take effect within 24 hours; to apply within 30 minutes: Set-User -Identity scanner@contoso.com -STSRefreshTokensValidFrom $([System.DateTime]::UtcNow)
A narrower option than loosening a shared policy: create a separate policy that allows only SMTP, for example New-AuthenticationPolicy -Name "Allow SMTP AUTH" -AllowBasicAuthSmtp (the same AllowBasicAuth* switches work on New-AuthenticationPolicy and Set-AuthenticationPolicy), and assign it to the one device mailbox with Set-User -Identity scanner@contoso.com -AuthenticationPolicy "Allow SMTP AUTH". Microsoft also says that if Basic authentication stopped working and you haven't set up security defaults or authentication policies, Microsoft may have disabled it in your tenant as part of its wider security program: check Message Center for posts about Basic authentication.
Microsoft's recommended Conditional Access policy to block legacy authentication targets the client apps Exchange ActiveSync clients and Other clients and grants Block access. SMTP AUTH with a password falls under it. To confirm that is what is happening, open Entra ID > Monitoring & health > Sign-in logs, add the Client App column, filter on the legacy authentication protocols, and check the User sign-ins (non-interactive) tab too.
Microsoft's policy steps say to exclude only the accounts that must keep legacy authentication. If you exclude the device mailbox, exclude only that account and use it for nothing else. Legacy authentication doesn't support MFA, so an account that must pass MFA can't use Basic SMTP AUTH at all.
smtp.office365.com, port 587 (recommended) or 25, STARTTLS with TLS 1.2 or 1.3. Microsoft says a device that recommends or defaults to port 465 doesn't support the required TLS versions; an "SSL/TLS" setting on port 587 usually fails before authentication with SSL wrong version number.Microsoft recommends Modern authentication (OAuth) for client SMTP submission. Its OAuth article covers both delegated and app-only sign-in:
https://outlook.office.com/SMTP.Send, plus offline_access for refresh tokens, and send the token with AUTH XOAUTH2.SMTP.SendAsApp application permission, have an admin consent, register the app's service principal in Exchange with New-ServicePrincipal -AppId <APPLICATION_ID> -ObjectId <OBJECT_ID> (the Object ID from Enterprise applications, not App registrations), grant it the mailbox with Add-MailboxPermission -Identity "sender@contoso.com" -User <SERVICE_PRINCIPAL_ID> -AccessRights FullAccess, and request the token with the scope https://outlook.office365.com/.default. To send as another address, grant Send As with Add-RecipientPermission.Microsoft describes SMTP AUTH as supporting OAuth in addition to Basic authentication, and the pages checked don't say OAuth bypasses the SMTP AUTH switches, so keep SmtpClientAuthenticationDisabled at $false on the mailbox the app uses.
If the device can't do OAuth, Microsoft's multifunction device article lists SMTP relay through an inbound connector (certificate or static IP, port 25) and Direct Send (internal recipients only), and points new setups to High Volume Email (internal recipients) and Azure Communication Services Email. The 5.7.57 guide compares them.
Microsoft's Basic authentication deprecation page says SMTP AUTH is currently available, that Microsoft has announced plans to retire Basic authentication for SMTP AUTH in Exchange Online, and that the retirement timeline has been updated. It refers readers to the latest announcement on the Microsoft Tech Community blog for the current milestones instead of listing dates, so this guide doesn't list dates either. Any device that still signs in with a username and password should be on your migration list now.
Need SPF, DMARC and MX checks across a whole client list? Run the Bulk SPF / DMARC / MX Auditor on Apify ($2 per 1,000 domains).
Confirm the tenant behind a domain with the M365 Tenant Lookup, find your MX endpoint for a relay connector with the MX Record Lookup, add relay IPs with the SPF Record Builder and check them with the SPF Record Checker, read test-message headers in the Email Header Analyzer and find more Exchange Online cmdlets in the PowerShell Cheat Sheet. Related guides: Exchange Online 5.7.57 (SMTP AUTH), Exchange Online 550 5.1.8, SSL wrong version number and SSL handshake failure.
Exchange Online refused the SMTP AUTH sign-in. Microsoft documents it as the organization configuration does not allow this authentication request: security defaults, the SMTP AUTH setting for the tenant or mailbox, an authentication policy or Conditional Access is blocking Basic authentication for SMTP.
Yes. Microsoft says that if security defaults are enabled, SMTP AUTH is already disabled in Exchange Online, and that you need to disable security defaults to use it. If you turn them off, Microsoft says to enable Conditional Access policies immediately to keep MFA and the legacy authentication block.
The mailbox setting is only one of several. An authentication policy without AllowBasicAuthSmtp, security defaults or a Conditional Access policy that blocks legacy authentication still stops Basic SMTP AUTH. Authentication policy changes take up to 24 hours unless you run Set-User with -STSRefreshTokensValidFrom.
Move the app to OAuth (the SMTP.Send scope for delegated sign-in, or SMTP.SendAsApp with an Exchange service principal for app-only), or send through an SMTP relay connector authenticated by certificate or static IP. Then you can keep security defaults or Conditional Access blocking legacy authentication.
Microsoft Learn says it has announced plans to retire Basic authentication for SMTP AUTH and that the timeline has been updated, and it points to the latest Microsoft Tech Community announcement for the current dates. Check that announcement for milestones.
Runbooks, checklists and helpdesk templates: IT Admin Packs on Gumroad.