WordPress Contact Forms and Microsoft 365
Problem Statement
Email to Microsoft 365 and other platforms with modern security authentication policies filter mail sent from WordPress as junk/spam.
Problem Explanation
Websites built in WordPress that have a contact form or another form mailers on the site typically use the built-in php mail() function to send messages from forms inside WordPress site to end-users on the Microsoft 365 mail plan. Using php mail() instead of the authorized mail relay for whatever mail service the domain is using (Microsoft 365 for example) will cause a mismatch between the sending server (WordPress) and the expected sending server (Microsoft 365) for a given domain.
This problem becomes even more problematic if Proofpoint (AES) is involved and filtering mail as well. But the solution below is the same.
Example
cooldomain.com (WordPress site) has a contact form configured to send email to customers as donotreply@cooldomain.com but the customer also has a Microsoft 365 email plan on cooldomain.com for regular business email.
Solution
WordPress must be switched from using php mail() as the SMTP relay to using Microsoft 365 as the SMTP relay.
Plugin Installation:
-
Navigate to Plugins → Add New Plugin
-
Search for Fluent SMTP
-
Install and Activate this plugin
-
Go to Settings > Fluent SMTP in WP Admin
-
Hit Skip
-
Select the Microsoft tile from the service provider selection page
-
Enter the From Email and From Name that emails should come from.
-
This should be the Microsoft 365 email, and it should be a real user in Microsoft 365.
-
-
Copy the App Callback URL
-
Search for the customer’s tenant in Microsoft Partner Center
-
Click Entra ID for the customer to launch the Entra portal for this tenant
-
Click Applications > App Registrations
-
Click +New Registration
-
Enter Fluent SMTP for the name
-
Select Accounts in any organizational directory (Any Microsoft Entra ID tenant - Multitenant)
-
Paste the copied App Callback URL in the Redirect URI field (this was Step 8 above)
-
Choose Web on the Select a platform dropdown menu
-
Click Register
-
Copy the Application (client) ID from Entra and paste it into the Application Client ID field on the Fluent SMTP setup page
-
Go back to Entra and click Add a certificate or secret next to Client Credentials
-
Click New client secret
-
Enter Fluent SMTP for the description
-
Choose 730 days (24 months) next to Expires
-
Click Add
-
Copy the secret in the Value column in Entra and paste it into the Application Client Secret field on the Fluent SMTP setup page
-
Click Authenticate with Office365 & Get Access Token
-
Enter the Microsoft 365 email address you entered for From Email in Step 7
-
You will be redirected to GoDaddy’s SSO to enter customer Microsoft 365 email password
-
Copy the entire Access Token (triple click in windows to select all, then copy)
-
Paste the Access Token in the Access token field in Fluent SMTP and click Save Connection Settings
-
To the right in Fluent SMTP, ensure Outlook for Office 365 is selected for the Default Connection
WordPress should now send through Microsoft 365 instead of php mail().
Bender-led Solution (Requires Admin Permissions)
WordPress Plugin Installation:
-
Open a new Incognito window
-
Skip in the the account in CRM.
-
Skip into the customer’s WP Admin
-
Pull the tenant in Bender and ensure MFA or SecDef is off for the user we are going to authenticate.
-
Navigate to Plugins → Add New Plugin
-
Search for Fluent SMTP
-
Install and Activate this plugin
-
Go to Settings > Fluent SMTP in WP Admin
-
Hit Skip
-
Select the Microsoft tile from the service provider selection page
- Enter the From Email and From Name that emails should come from.
-
This should be the Microsoft 365 email, and it should be a real user in Microsoft 365.
-
-
Copy the App Callback URL
-
In Bender, go to the Tenant Dash
-
Click the Azure App Registration tile
-
Enter the App Callback URL from Step 8 and click Create App Registration
-
Copy the Client ID (Application Client ID) and the Client Secret (Application Client Secret) from the Bender response and paste them into the Fluent SMTP Plugin Setup page in WP Admin.
-
Click Authenticate with Office365 & Get Access Token
-
Go to cAuth and search for the customer
-
Skip into the customer’s M365 Mailbox
-
Note: If the customer has Security Defaults, you will need to temporarily disable it to skip into their M365
-
-
Go back to the Fluent SMTP plugin and click Authenticate with Office365 & Get Access Token
-
Copy the entire Access Token (triple click in windows to select all, then copy)
-
Paste the Access Token in the Access token field in Fluent SMTP and click Save Connection Settings
-
To the right in Fluent SMTP, ensure Outlook for Office 365 is selected for the Default Connection and Save again.