Using Single Tenant With the Outlook Mailer

Heads up! This article contains PHP code and is intended for developers. We offer this code as a courtesy but don’t provide support for code customizations or 3rd party development.

Overview

Would you like to use a single tenant with the Outlook mailer in your WordPress site? Setting up your site to use a specific tenant ID when communicating with Outlook’s API allows for more customized and controlled integration.

In this tutorial, we’ll show you how to set the Outlook API authorization and access token URLs to use your unique tenant ID.

Note: Be sure to install and activate the WP Mail SMTP plugin on your site before adding the code snippet provided in this tutorial.

Setup

We recommend that you copy and paste the required snippet below into a new WPCode snippet. WPCode makes it easy and safe to run code snippets on your site.

For help with adding snippets to your site, please see our tutorial on adding code snippets using the WPCode plugin.

Simply copy and paste the snippet below to your site. On line 2 and line 6, you’ll need to replace my_tenant_id with your actual tenant ID.

add_filter( 'wp_mail_smtp_pro_providers_outlook_auth_authorize_url', function ( $url ) {
 $tenant_id = 'my_tenant_id';
 return str_replace( '/common/', ""/{$tenant_id}/"", $url );
} );
add_filter( 'wp_mail_smtp_pro_providers_outlook_auth_access_token_url', function ( $url ) {
 $tenant_id = 'my_tenant_id';
 return str_replace( '/common/', ""/{$tenant_id}/"", $url );
} );

That’s it! Now you know how to successfully use a single tenant with the outlook mailer on your WordPress site.

Next, want to explore more ways to customize your WP Mail SMTP setup? Be sure to look at our other code snippets for more customization options.