Microsoft Office 365 – Post SMTP

NEW YEAR MEGA DEALS

Only On Lifetime Plans

Offer Ends In

-
DAYS
-
hrs
-
min
-
sec

Microsoft Office 365

Estimated reading: 2 minutes 950 views

This documentation is intended for developers and contains PHP code examples. If you’re not familiar with PHP or WordPress development, we recommend avoiding custom code changes to prevent performance issues with your site.

Would you like to configure a single tenant for your Microsoft Office 365 integration in Post SMTP? By specifying a tenant ID, you can ensure tighter control and compliance when authenticating with Microsoft’s Graph API.

In this guide, we’ll show you how to adjust the authorization and access token URLs in Post SMTP to use your Microsoft Azure tenant ID instead of the default /common/ endpoint.

Note: Make sure the Post SMTP plugin is installed and activated on your WordPress site before proceeding.

Code Snippet

To use a specific tenant ID with Office 365, you’ll need to add the following code to your site. This snippet modifies the default Microsoft OAuth URLs used by Post SMTP by inserting your tenant ID.

add_filter( 'post_smtp_office365_authorize_url', function( $url ) {
	$tenant_id = 'YOUR_AZURE_TENANT_ID'; // Replace with your Azure Tenant ID
	return str_replace( '/common/', "/{$tenant_id}/", $url );
} );

add_filter( 'post_smtp_office365_access_token_url', function( $url ) {
	$tenant_id = 'YOUR_AZURE_TENANT_ID'; // Replace with your Azure Tenant ID
	return str_replace( '/common/', "/{$tenant_id}/", $url );
} );

Be sure to replace ‘YOUR_AZURE_TENANT_ID’ with your actual Azure Directory (tenant) ID in both filters.

You can add this code to your theme’s functions.php file or a custom plugin if you prefer keeping modifications separate from theme updates.

Looking to customize more aspects of Post SMTP? Browse our Action Hooks and Filter Hooks guides for further enhancements.

Share this Doc

Microsoft Office 365

Or copy link

CONTENTS
👋 Having issues sending email
in WordPress? Lets Chat 👇
Scroll to Top