How to Set Up the Microsoft 365 / Mailer in WP Mail SMTP

Would you like to use your Outlook and Microsoft 365 account to improve email deliverability for your WordPress site? The Microsoft 365 / mailer for WP Mail SMTP lets you securely use Microsoft’s API to authenticate your site’s emails.

In this tutorial, we’ll show you every step needed to set up the Microsoft 365 / mailer in WP Mail SMTP.

Requirements: This mailer requires your site to have SSL (https) enabled. For setup details, please see WPBeginner’s guide to adding SSL and HTTPS in WordPress.

Also, while this mailer setup does not require the use of any paid Microsoft services, Microsoft will require that you enter a credit card to set up an account (to reduce spam signups).

Please also note that the Microsoft 365 / mailer is only available with the Pro license or higher.

What is the Microsoft 365 / Mailer?

Microsoft offers not only email address/inbox services but also a tool to improve the deliverability of your emails. They do this through an API, which means that you don’t have to enter any sensitive login details into your WordPress admin area (which is more secure than a traditional SMTP).

Microsoft offers this service for free to anyone with one of their email accounts ([email protected], [email protected], or a Microsoft 365 email address).

The Microsoft 365 / mailer can send up to 10,000 emails per minute, which is much higher than the limits on most other mailers. However, Microsoft’s setup requirements are more complex than most other mailer options in WP Mail SMTP.

If this mailer sounds like a good fit for your site, then let’s get started!

Getting Started with WP Mail SMTP

To get started, you’ll first need to install and activate the WP Mail SMTP plugin.

Once you’ve installed and activated the plugin, go to WP Mail SMTP » Settings. This will open up a list of all available settings, and we’ve outlined each of them below:

From Email and From Name

You can skip both of these settings, as anything here will be overridden by the settings within your Outlook and Microsoft 365 account (later on, you’ll notice that these fields both end up disabled).

From Email and From Name in WP Mail SMTP


The Mailer field is where you’ll need to choose the mailer you’d like your site to use. To configure the Microsoft 365 / mailer, go ahead and select the 365 / Outlook option.

Select Outlook mailer

Now that you’ve chosen the Microsoft 365 / mailer, you should see a new section appear titled Outlook / 365.

Outlook 365 Settings in WP Mail SMTP

To generate the information needed for this section, you’ll need to set up a web application within a Microsoft Azure account. This process doesn’t require any coding, and we’ll show you exactly what to do in the next step.

Be sure to keep these WP Mail SMTP settings open in a separate tab or window, as you’ll come back to them soon.

Configuring a Microsoft Azure Account

In order to move forward with the setup process, you’ll need to have a Microsoft Azure account.

Since you most likely already have a Microsoft email account (through Hotmail, Live, Outlook, Microsoft 365, etc), you can simply log into Microsoft Azure with your existing account credentials.

If you need to create a brand new account, you can click this link to sign up for a free Microsoft Azure account.

Note: The email you use for your Azure account must be a Microsoft-based email address that includes email sending permissions. This account email must also be the email address you’d like to use as the From Email on your website.

Next, you’ll need to open the Azure Portal, if you’re not automatically redirected.

Create an Application ID

Once the Azure Portal is open, type App registrations in the search bar at the top of the page.

Search app registrations

Next, you’ll see a dropdown menu with a list of services. Go ahead and click on App registrations.

Click app registrations

At the top of the App Registrations page, you’ll need to select the + New Registration option.

Click on New Registration

In the app registration form, here are the details you’ll need to fill out:

  • Name: This is only for your personal organization, so we recommend naming it something like “WP Mail SMTP:”.
  • Supported account types: Select Accounts in any organizational directory and personal Microsoft accounts.

Example of app registration form in Microsoft

Note: For some Microsoft account types, you may only see the Accounts in any organizational directory (Any Azure AD – Multitenant) option. Go ahead and select this option if the Accounts in any organizational directory and personal Microsoft accounts option doesn’t appear for your account type.

  • Redirect URI: For the first dropdown, leave this set to Web. Then for the second field, you’ll need to copy this value from your WP Mail SMTP settings (see below).

In order to find the Redirect URI, you’ll need to switch back to the tab or window where you left your site’s WP Mail SMTP settings open. Under the Outlook / 365 section, you’ll see a field named Redirect URI.

Copy Redirect URI from WP Mail SMTP settings

You’ll need to copy this value, then paste it into your Microsoft Azure app registration form. Be sure to still keep both windows/tabs open in your browser, as we’ll continue to switch between the two.

Finish app registration form in Microsoft

When you’re ready, click the Register button to proceed.


As soon as this registration form is submitted, you should see a page that includes Application (client) ID. Go ahead and copy this value.

Copy Application ID from Microsoft

Once you have the Application (client) ID copied, you’ll need to paste this full value into your WP Mail SMTP settings, in the field labeled Application ID.

Paste Application ID into WP Mail SMTP settings

Create an Application Password

Next, we’ll need to generate a password for this app. To do that, click on Certificates & secrets in the left sidebar.

Open Certificates and Secrets menu item

On this screen, skip down to the Client secrets section. Then, select + New client secret.

Create a new client secret in Microsoft settings

An overlay will appear, and here you’ll need to fill out a short form:

  • Description: This name is only for your own use, so we recommend a logical and simple name such as app_password.
  • Expires: 24 months

Add a client secret

After you submit the client secret form, the Application Password will be generated. Go ahead and copy the password under the Value section, and head back over to your WP Mail SMTP settings.

Copy client secret from Microsoft account

Once you’ve returned to the tab or window where your settings are still open, paste this value into the Application Password field.

Paste client secret into Application Password field in WP Mail SMTP

Set Up API Permissions

Now that you’ve got both the Application ID and Application password filled out in WP Mail SMTP, the next step is to set up API permissions. To get started, you’ll need to click on API permissions in the white left menu.

Then, click on the + Add a permission option.

Add a permission to your Microsoft API

This will open a page titled Request API Permissions. Here, you’ll need to click the large top option named Microsoft Graph.

Click on the Microsoft Graph option

You’ll only need to fill out a couple pieces of information on this page:

  • What type of permissions does your API require: Choose the option named Delegated permissions

Choose delegated permissions for Microsoft API

  • Select permissions: Type in send. Then, from the options that appear, check Mail.Send.Shared.

Provide mail sending permissions

When you’re ready, click the Add permissions button to proceed.

Click add permissions button

Next, you’ll need to go through this permissions process once more in a slightly different way. To do this, go ahead and click on + Add a permission again, followed by the Microsoft Graph option.

Here are the new details you’ll need for this additional set of permissions:

    • What type of permissions does your API require: Choose the option named Application permissions.

Add application permissions in Microsoft

  • Select permissions: Type in send. Then, from the options that appear, check Mail.Send.

Add mail sending permissions to app

Once again, click the Add permissions button when you’re ready to proceed.

Note: If you are using a Microsoft 365 email, you may also need to grant admin permissions for your app. For more details on how to set this up, please check out Microsoft’s tutorial on granting admin consent for Enterprise apps.

Now that your API permissions are all set in Microsoft’s system, we can finish up the configuration in WP Mail SMTP.

Saving Settings and Authorizing WP Mail SMTP

Back in the WP Mail SMTP settings, you should now have all fields filled out. After checking this over, you can click Save Settings at the bottom of the page.

Save WP Mail SMTP settings

After you’ve saved the settings, you’ll need to scroll down to the Authorization setting. You should now see a button labeled Allow plugin to send emails using your Microsoft account.

Provide authorization for Microsoft account

As soon as you click this button, you should be redirected to a Microsoft permissions form.

Microsoft permissions request form

At the bottom of this form, click Yes.

Next, you will be redirected back to your WP Mail SMTP settings. At the top of these settings, you should see a notification letting you know that you’ve successfully connected your Microsoft account.

Microsoft API has been successfully connected

Sending a Test Email

Now that your Microsoft API is set up and connected, it’s important to send a test email to ensure that everything is working properly. To do this, make sure you’re on the Settings » WP Mail SMTP page and then open the Email Test tab.

Open the Email Test tab in WP Mail SMTP

On this tab, you can enter any email address that you have access to (the default will be the site’s admin email). Then, click the Send Email button.

After sending the email, you should see a success message.

Wp Mail SMTP test email success message

If you check the inbox for that email address, you should receive the email for this test.

Successful test email from WP Mail SMTP

Frequently Asked Questions

I use Two Factor Authentication / Multi Factor Authentication (2FA / MFA) on my Microsoft-based email account. Will that work with the Microsoft 365 / mailer?

If you already have 2FA/MFA configured before completing the setup steps in this tutorial, then you shouldn’t run into any issues (just follow the steps as normal).

If you complete this tutorial and then decide to later enable 2FA/MFA, however, then in most cases you’ll need to re-authorize the mailer (see Saving Settings and Authorizing WP Mail SMTP).

What is the maximum email size that can be sent through the Microsoft 365 / mailer?

Currently, the Microsoft 365 / mailer has a maximum size limit is 4MB.

Why do I receive the following error when setting up an Office 365 GCC or DoD email address?

Confidential Client is not supported in Cross Cloud request

For security measures, Government Community Cloud (GCC) and U.S. Department of Defense (DoD) accounts typically use the .us domain extension instead of .com. In order to set up these types of accounts, you’ll need to add the following code snippet to allow for .us domain extensions:

function theme_prefix_enable_gcc_high_and_dod_compatibility( $country_code ) {

	add_filter( 'wp_mail_smtp_pro_providers_outlook_auth_authorize_url', function ( $url ) use ( $country_code ) {
		return str_replace( '', 'microsoftonline.' . $country_code, $url );
	} );

	add_filter( 'wp_mail_smtp_pro_providers_outlook_auth_access_token_url', function ( $url ) use ( $country_code ) {
		return str_replace( '', 'microsoftonline.' . $country_code, $url );
	} );

	add_filter( 'wp_mail_smtp_pro_providers_outlook_auth_resource_owner_details_url', function ( $url ) use ( $country_code ) {
		return str_replace( '', 'microsoft.' . $country_code, $url );
	} );

	add_filter( 'wp_mail_smtp_pro_providers_outlook_auth_get_scopes', function ( $scopes ) use ( $country_code ) {
		return array_map( function ( $url ) use ( $country_code ) {
			return str_replace( '', 'microsoft.' . $country_code, $url );
		}, $scopes );
	} );

	add_filter( 'wp_mail_smtp_pro_providers_outlook_mailer_api_url', function ( $url ) use ( $country_code ) {
		return str_replace( '', 'microsoft.' . $country_code, $url );
	} );

// Define country code as first parameter.
theme_prefix_enable_gcc_high_and_dod_compatibility( 'us' );

If you need to account for a domain extension with a different country code, such as .de, simply replace 'us' with your country code, in the last line of the code provided above. For example, theme_prefix_enable_gcc_high_and_dod_compatibility( 'de' );

Note: For extra guidance, please see WPBeginner’s tutorial on adding custom code.

That’s it! You have successfully set up your site to send WordPress emails with the Microsoft 365 / mailer in WP Mail SMTP.

Next, would you also like to control which emails WordPress core sends out? Be sure to check out our tutorial on Email Controls for all the details.