Skip to content

WordPress Microsoft 365 email: fix 535 5.7.139 with OAuth

Fix WordPress email that Microsoft 365 refuses with 535 5.7.139 by replacing the SMTP password with OAuth sign-in. You will register an app in Microsoft Entra ID, connect it in FluentSMTP, and prove that contact forms and order emails arrive again.

Your WordPress contact forms, WooCommerce order emails or password resets go out through a Microsoft 365 mailbox, and the SMTP plugin log now says 535 5.7.139 Authentication unsuccessful, basic authentication is disabled. Microsoft is refusing password sign-in for the plugin’s connection to smtp.office365.com, even when the password is correct. The lasting fix is to stop sending a password at all. Register an app in Microsoft Entra ID (Microsoft’s sign-in service for work accounts), and let your SMTP plugin send through Microsoft Graph, Microsoft’s web API for mailboxes, with a short-lived token. The steps below use FluentSMTP, which includes that connection in its free version, and end with a test that proves the mail arrived.

What you’ll accomplish

  • Confirm that Microsoft is refusing password sign-in, not a typo.
  • Pick the replacement that fits a WordPress host.
  • Register an Entra ID app with the narrowest permissions that can still send mail.
  • Connect FluentSMTP to that app and remove the old password from WordPress.
  • Prove delivery end to end, and know which error to expect when the client secret expires.

Prerequisites

  • WordPress 6.5 or newer on PHP 7.4 or newer, which is what FluentSMTP 2.4.1 requires.
  • The Microsoft 365 mailbox WordPress sends from, with its password. It must be a licensed user mailbox, because you will sign in as it once.
  • An account that can register apps in Microsoft Entra ID (at least the Application Developer role), and someone who can grant admin consent, usually a Global Administrator.
  • Your site on HTTPS, with a known final address such as https://example.com. The sign-in flow returns to that exact address.
  • Optional: WP-CLI (the WordPress command-line tool) for the test commands. Every step also works from wp-admin.

How it works

SMTP AUTH is how an app hands a mailbox name and password to smtp.office365.com on port 587. It has long been off by default for many tenants (a tenant is your organization’s own space in Microsoft 365). Microsoft’s documentation notes it is disabled for organizations created after January 2020, and that turning on security defaults (Microsoft’s baseline sign-in protections) disables it too. That is why some sites already see 5.7.139 today.

Microsoft’s Exchange Team post of January 27, 2026 (checked October 17, 2026) sets the timeline for everyone else. Basic authentication for SMTP AUTH stays as it is until December 2026. At the end of December 2026 it is disabled by default for existing tenants, though admins can still turn it back on. New tenants created after that date do not get it by default. Microsoft says it will announce the final removal date in the second half of 2027. Dates have moved before, so check the Exchange Team announcement if you read this later.

Two send paths side by side. Old path: the WordPress plugin sends a username and password to smtp.office365.com on port 587 with AUTH LOGIN, and the login is refused with 535 5.7.139, basic authentication is disabled. New path: the plugin holds a client ID and secret, you sign in once and consent, Entra ID issues a token with Mail.Send, the plugin calls Microsoft Graph POST /me/sendMail over HTTPS, and the message is sent with 202 Accepted.

On the left, Microsoft refuses the password at the login step, so nothing is queued. The right column is the replacement. OAuth 2.0 is a sign-in standard where an app receives a short-lived token instead of a password. You sign in as the mailbox once, Entra ID checks that the app may send mail for you, and the plugin stores a refresh token. From then on, each message is an HTTPS call to Microsoft Graph. Graph answers 202 Accepted and saves a copy in the mailbox’s Sent Items. Graph does not use SMTP AUTH at all, so this path keeps working whatever the SMTP AUTH settings are.

Your choices, and why most WordPress sites pick the first:

  • OAuth through Graph, using your existing mailbox. No new vendor, no DNS changes, and the password leaves WordPress. FluentSMTP offers it free as “Outlook or Office 365”; in WP Mail SMTP the Microsoft mailer is a Pro feature, covered in the WP Mail SMTP setup guide.
  • A transactional email provider, such as Postmark, Amazon SES or Brevo. Pick this when a store sends a lot of mail. One mailbox has sending limits; for SMTP submission Microsoft lists 10,000 recipients a day and 30 messages a minute.
  • SMTP relay through a Microsoft 365 connector. It needs an unshared static IP address or a certificate, plus port 25, and Microsoft says it cannot be used from a third-party hosted service. A shared cPanel server fails on all counts.
  • Direct send. It only delivers inside your own Microsoft 365 organization, so customers never get their order emails.
  • Turning SMTP AUTH back on for one mailbox. A stopgap that ends when Microsoft removes the feature.

Step-by-step

  1. Confirm what Microsoft is refusing. In FluentSMTP or WP Mail SMTP, open the email log and read the full error from a failed send. To test outside WordPress, run swaks (a small SMTP test tool, in most Linux package managers) from any machine with port 587 open:
swaks --server smtp.office365.com:587 --tls --auth LOGIN \
  --auth-user wordpress@example.com --auth-password 'the-mailbox-password' \
  --from wordpress@example.com --to you@example.net

Example output (the authentication exchange):

<~  250-AUTH LOGIN XOAUTH2
 ~> AUTH LOGIN
<~  334 VXNlcm5hbWU6
 ~> d29yZHByZXNzQGV4YW1wbGUuY29t
<~  334 UGFzc3dvcmQ6
 ~> dGhlLW1haWxib3gtcGFzc3dvcmQ=
<~* 535 5.7.139 Authentication unsuccessful, basic authentication is disabled. [YT3PR01CA0118.CANPRD01.PROD.OUTLOOK.COM 2026-10-17T13:42:51.208Z 08DF2C5B71A0E4C3]
*** No authentication type succeeded

The code after 535 tells you which problem you have:

  • 5.7.139 with “basic authentication is disabled”: password sign-in is blocked by policy. Continue with step 2.
  • 5.7.139 with “SmtpClientAuthentication is disabled for the Tenant”: SMTP AUTH is switched off for the whole organization. Step 2 is still the fix.
  • 535 5.7.3 Authentication unsuccessful: Microsoft did not accept the name and password. Check them by signing in at outlook.office.com. If that works, the OAuth switch still fixes it.
  • 235 2.7.0 Authentication successful: password sign-in still works today. Microsoft is not refusing it yet, so read the rest of the plugin log for the real error, then plan this switch before the end of December 2026.
  1. Install FluentSMTP and copy its callback address. From wp-admin, go to Plugins → Add New Plugin and install FluentSMTP, or use WP-CLI:
wp plugin install fluent-smtp --activate

Example output:

Installing FluentSMTP – WP Mail SMTP Plugin with Amazon SES, SendGrid, Mailgun, Postmark, Cloudflare, toSend, Gmail and Any SMTP (2.4.1)
Downloading installation package from https://downloads.wordpress.org/plugin/fluent-smtp.2.4.1.zip...
Unpacking the package...
Installing the plugin...
Plugin installed successfully.
Activating 'fluent-smtp'...
Plugin 'fluent-smtp' activated.
Success: Installed 1 of 1 plugins.

If WP-CLI prints Warning: fluent-smtp: Plugin already installed., run wp plugin activate fluent-smtp instead. Then go to Settings → FluentSMTP, select Add Connection, and choose Outlook or Office 365. Copy the field labelled App Callback URL (paste this into your Microsoft app). With normal permalinks it looks like https://example.com/wp-json/fluent-smtp/outlook_callback. With Plain permalinks it uses index.php?rest_route= instead.

  1. Register the app in Entra ID. Sign in to the Microsoft Entra admin center at https://entra.microsoft.com. Go to Entra ID → App registrations → New registration, then fill in:
  • Name: WordPress mail - example.com, so the next admin knows what it is.
  • Supported account types: the single-tenant option, “Single tenant only” in the current wording or “Accounts in this organizational directory only” in older screens. Only your own staff accounts can then use the app.
  • Redirect URI: platform Web, value pasted exactly from step 2.

Select Register. The app’s Overview page opens. Copy the Application (client) ID and the Directory (tenant) ID, two values that each look like 3f8c2a71-5b0e-4d9a-a6c4-91e27b0d58f3. If Register stays greyed out, a required field is empty or the redirect address is not a valid https:// URL.

  1. Create a client secret and note its expiry date. Go to Certificates & secrets → Client secrets → New client secret. Enter the description WordPress mail, and choose 365 days (12 months) under Expires. Microsoft caps secrets at 24 months and recommends less than 12, so a yearly renewal is a fair middle ground. Select Add. A new row appears with an Expires date. Copy its Value column right away; it is never shown again. Do not copy the Secret ID, which looks similar and will not work. Set a calendar reminder two weeks before expiry, because mail stops that day.

  2. Add the send permissions and grant admin consent. Go to API permissions → Add a permission → Microsoft Graph → Delegated permissions. Delegated means the app acts as the signed-in mailbox and nothing more. Add these three, which are exactly what FluentSMTP asks for. Leave User.Read, which Entra adds to every new app, where it is.

  • Mail.Send: send mail as the signed-in mailbox.
  • Mail.Send.Shared: send as a shared mailbox, but only where that user already has Send As rights.
  • offline_access: keep a refresh token, so the plugin works without you signing in again.

Then select Grant admin consent for your tenant name, then Yes. Admin consent means an administrator approves these permissions once for the whole tenant, so nobody sees a blocked approval screen later. After a refresh, the Status column should read “Granted for” your tenant on every line. If the button is greyed out, your role cannot grant consent; ask a Global Administrator to do this one click.

  1. Connect FluentSMTP. Back in the FluentSMTP tab, fill in:
  • From Email: the mailbox address, such as wordpress@example.com. Turn on Force From Email (recommended), so a form plugin cannot put a visitor’s address in From.
  • Application Client ID and Application Client Secret: from steps 3 and 4. You can choose Store in wp-config.php instead; FluentSMTP then reads the FLUENTMAIL_OUTLOOK_CLIENT_ID and FLUENTMAIL_OUTLOOK_CLIENT_SECRET constants and shows the snippet to paste.
  • Directory (tenant) ID: the value from step 3. FluentSMTP marks the field Optional and falls back to common, but a single-tenant app needs its own ID here.

Select Authenticate with Office365. In the Microsoft window, sign in as the sending mailbox, not as your admin account, because the token belongs to whoever signs in. If Microsoft shows a permissions prompt, select Accept. Back in WordPress, select Save Connection Settings. Reopen the connection: it should read “Outlook / Office365 is connected and nothing else is needed here”.

  1. Remove the old path. Deactivate any other SMTP plugin, because two plugins that both replace WordPress mail sending will fight over each message. Then delete the stored mailbox password from the old plugin settings or from wp-config.php. If no other device or app uses SMTP AUTH on that mailbox, an admin can turn it off. In Exchange Online PowerShell, run Connect-ExchangeOnline first, then:
Set-CASMailbox -Identity wordpress@example.com -SmtpClientAuthenticationDisabled $true
Get-CASMailbox -Identity wordpress@example.com | Format-List SmtpClientAuthenticationDisabled

Example output:

SmtpClientAuthenticationDisabled : True

True means password sign-in is now closed for that mailbox, which the OAuth connection never uses. A blank value means the mailbox still follows the tenant-wide setting, so check that the first command ran without an error.

Validate it works

  1. Send a test from FluentSMTP. Open Email Test, choose your From address, enter an outside mailbox you can read (a Gmail address is fine), and select Send Test Email. The notice “Email delivered successfully.” means Graph returned 202 Accepted. A red error instead shows Microsoft’s own message; match it against the Troubleshooting list below.

  2. Send through WordPress itself. This goes through wp_mail(), the same function your forms and WooCommerce call:

wp eval 'var_dump( wp_mail( "you@example.net", "Graph send test", "Sent from WordPress through Microsoft Graph." ) );'

Example output:

bool(true)

bool(false) means the send failed. Open Settings → FluentSMTP → Email Logs and read the error on the newest entry.

  1. Look in the mailbox’s Sent Items. Sign in to Outlook on the web as the sending mailbox. Both test messages should sit in Sent Items, because Graph saves a copy there by default. This is the clearest proof that Microsoft accepted them.

  2. Check authentication at the receiving end. In Gmail, open the message, choose More → Show original, and find Authentication-Results.

Example output:

Authentication-Results: mx.google.com;
       dkim=pass header.i=@example.com header.s=selector1 header.b=Kq3vR8xT;
       spf=pass (google.com: domain of wordpress@example.com designates 2a01:111:f403:c10c::1 as permitted sender) smtp.mailfrom=wordpress@example.com;
       dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=example.com

All three should say pass. If spf fails, check that your SPF record (the DNS list of servers allowed to send for your domain) includes Microsoft 365:

dig +short TXT example.com | grep spf1

Example output:

"v=spf1 include:spf.protection.outlook.com -all"

Troubleshooting

  • AADSTS50011, the redirect URI does not match. Common causes are http versus https, www versus no www, a trailing slash, or Plain permalinks. Copy the App Callback URL from FluentSMTP again and paste it under Authentication in the app registration.
  • AADSTS50194, the app is not configured as multi-tenant. The Directory (tenant) ID field in FluentSMTP is empty, so the sign-in went to the shared common endpoint. Paste the Directory (tenant) ID from the app’s Overview page, save, and authenticate again.
  • AADSTS65001 or AADSTS90094, consent is missing. The tenant does not let ordinary users approve apps, so admin consent was never granted. Repeat step 5 as an administrator, then select Authenticate with Office365 again.
  • Mail stopped months later with AADSTS7000222. That code means the client secret expired. Create a new secret (step 4), paste the new Value into FluentSMTP, save, and authenticate again. Then set the next reminder.
  • 403 ErrorSendAsDenied when sending as info@ or another address. Graph refuses a From address that the signed-in mailbox has no right to use. For a shared mailbox, an admin opens the Exchange admin center and goes to Recipients → Mailboxes. They select the shared mailbox, open its Delegation tab (Manage mailbox delegation in older screens), and add the sending user under Send as. Or set From Email back to the signed-in mailbox.
  • Mail arrives but lands in spam. Mail now leaves from Microsoft’s servers. SPF needs include:spf.protection.outlook.com, and DKIM (a signature that proves the message was not altered) must be on for your domain. In the Microsoft Defender portal, open https://security.microsoft.com/authentication and select the DKIM tab. The email-going-to-spam audit walks through the rest.

When this is the wrong approach

If the site sends newsletters, or a store sends thousands of messages a day, one mailbox is the wrong tool, and FluentSMTP itself warns against this connection for mass marketing. Use a transactional provider on a subdomain such as mail.example.com. Without admin access to the tenant you cannot finish step 5, so send these steps to whoever manages it. If you only need time, an admin can tick Authenticated SMTP for this mailbox in the Microsoft 365 admin center, under Users → Active users → the user → Mail → Manage email apps. That buys time until Microsoft’s final removal date. Microsoft documents the SMTP AUTH settings on Enable or disable SMTP AUTH in Exchange Online.

Running WordPress that earns real money deserves an operator — Stack Harbor runs that stack under Enterprise WordPress; book an infrastructure consult.