OAuth SMTP Configuration for Microsoft 365
Important
Microsoft is deprecating Basic Authentication for SMTP:
- March 1, 2026: Microsoft begins rejecting Basic Auth for SMTP submissions
- April 30, 2026: 100% rejection of Basic Auth SMTP submissions
If you use Microsoft 365 or Office 365 for SMTP, you must configure OAuth 2.0 authentication before March 2026.
Note
Supported Versions: OAuth SMTP configuration is supported in XMPro 4.6 and later.
Overview
XMPro supports OAuth 2.0 authentication for SMTP using the client credentials grant flow. This is Microsoft's recommended replacement for Basic Authentication and provides enhanced security through token-based authentication.
This guide covers Azure AD app registration, platform-specific configuration for each deployment method, testing and verification, troubleshooting common issues, and migration from Basic Auth.
When to use OAuth SMTP:
- Required: When using Microsoft 365 or Office 365 SMTP after March 2026
- Recommended: For any email service that supports OAuth 2.0 authentication
- Not Required: For SMTP servers that continue supporting Basic Authentication
Prerequisites
Before configuring OAuth SMTP in XMPro, you need:
Azure Active Directory access with permissions to:
- Create app registrations
- Grant admin consent for API permissions
Microsoft 365 mailbox configured for sending email
XMPro deployment method:
- Azure Terraform
- Windows Server installer
Azure AD App Registration
Step 1: Create App Registration
Sign in to the Azure Portal
Navigate to Azure Active Directory > App registrations
Click New registration:
- Name:
XMPro SMTP OAuth(or your preferred name) - Supported account types: Accounts in this organizational directory only (Single tenant)
- Redirect URI: Leave blank
- Click Register
- Name:
Note the following values (you'll need them for XMPro configuration):
- Application (client) ID - Located on the Overview page
- Directory (tenant) ID - Located on the Overview page
Step 2: Create Client Secret
In your app registration, go to Certificates & secrets
Click New client secret:
- Description:
XMPro SMTP Secret(or your preferred description) - Expires: Choose an appropriate expiration (Recommended: 12 or 24 months)
- Click Add
- Description:
Copy the secret value immediately - You won't be able to see it again!
- Store this securely - you'll need it for XMPro configuration
Warning
Secret Expiration: Client secrets expire after the chosen period. Set a calendar reminder to rotate the secret before it expires to avoid SMTP failures.
Step 3: Configure API Permissions
In your app registration, go to API permissions
Click Add a permission > APIs my organization uses
Search for and select Office 365 Exchange Online
Select Application permissions (not Delegated permissions)
Add these two permissions:
- SMTP.SendAsApp - Send mail using SMTP AUTH protocol
- Mail.Send - Send mail as any user
Click Add permissions
Grant admin consent:
- Click Grant admin consent for [Your Organization]
- Confirm when prompted
- Wait for the status to show "Granted for [Your Organization]"
Note
Admin Consent Required: Application permissions require admin consent. If you don't see the "Grant admin consent" button, contact your Azure AD administrator.
Step 4: Enable SMTP AUTH in Exchange Online
Important
SMTP AUTH is disabled by default in Microsoft 365 for security. Even with OAuth 2.0, administrators must explicitly enable it.
Microsoft 365 tenants have SMTP authentication disabled by default. You must enable SMTP AUTH either globally or for specific mailboxes before OAuth SMTP will work.
Option 1: Enable SMTP AUTH Globally (Recommended for XMPro)
Use this option if XMPro will send emails from multiple mailboxes or if you want a simpler configuration.
Install Exchange Online PowerShell (if not already installed):
Install-Module -Name ExchangeOnlineManagement -Scope CurrentUserConnect to Exchange Online:
Connect-ExchangeOnlineYou'll be prompted to authenticate with your admin credentials.
Enable SMTP AUTH globally:
Set-TransportConfig -SmtpClientAuthenticationDisabled $falseVerify the setting:
Get-TransportConfig | Format-List SmtpClientAuthenticationDisabledShould return:
SmtpClientAuthenticationDisabled : False
Option 2: Enable SMTP AUTH for Specific Mailbox
Use this option for a more restrictive security posture, enabling SMTP AUTH only for the mailbox XMPro will use.
Connect to Exchange Online (same as above)
Enable SMTP AUTH for specific mailbox:
Set-CASMailbox -Identity your-email@yourdomain.com -SmtpClientAuthenticationDisabled $falseReplace
your-email@yourdomain.comwith the mailbox XMPro will use to send emails.Verify the setting:
Get-CASMailbox -Identity your-email@yourdomain.com | Format-List SmtpClientAuthenticationDisabledShould return:
SmtpClientAuthenticationDisabled : False
For detailed instructions, see Microsoft's official guide on enabling SMTP AUTH.
Note
Security Defaults: If your organization has "Security Defaults" enabled in Azure AD, SMTP AUTH is disabled and cannot be enabled. You must disable Security Defaults first. See Microsoft Security Defaults documentation for more information.
Common Error Without This Step
If you skip this step, you'll see this error when attempting to send email:
535 5.7.139 Authentication unsuccessful, SmtpClientAuthentication is disabled for the Tenant
Solution: Complete this step to enable SMTP AUTH as shown above.
Step 5: Calculate Token Endpoint URL
Using your Directory (tenant) ID from Step 1, construct the token endpoint URL that XMPro will use to request OAuth tokens.
Your OAuth token endpoint URL follows this format:
https://login.microsoftonline.com/{tenant-id}/oauth2/v2.0/token
Replace {tenant-id} with your Directory (tenant) ID from Step 1.
Example:
https://login.microsoftonline.com/12345678-1234-1234-1234-123456789012/oauth2/v2.0/token
XMPro Configuration by Deployment Method
After completing the Azure AD app registration above, configure your XMPro deployment with the OAuth SMTP settings. Choose the section that matches your deployment method.
Azure Terraform Deployment
Add these variables to your terraform.tfvars file:
# Enable email notifications (required - defaults to false)
enable_email_notification = true
# Enable OAuth SMTP authentication
enable_email_oauth = true
# OAuth token endpoint (replace {tenant-id} with your Directory tenant ID)
email_oauth_token_endpoint = "https://login.microsoftonline.com/{tenant-id}/oauth2/v2.0/token"
# Azure AD application credentials
email_oauth_token_client_id = "your-application-client-id"
email_oauth_token_client_secret = "your-client-secret-value"
# OAuth scope (use this exact value for Microsoft 365)
email_oauth_token_scope = "https://outlook.office365.com/.default"
# Basic SMTP settings (still required with OAuth)
email_server = "smtp.office365.com"
email_server_ssl = true
email_server_port = 587
email_username = "notifications@yourdomain.com"
email_from_address = "notifications@yourdomain.com"
# Note: email_password is not used when OAuth is enabled
Note
The OAuth configuration applies to both SM and AD automatically in Terraform deployments.
For detailed Terraform configuration, see the Terraform module documentation.
Windows Server Deployment
During Installation
The Windows installer (v4.6+) supports OAuth SMTP configuration during installation:
When prompted "Enable SMTP configuration? (y/n)", answer
yProvide standard SMTP settings:
- SMTP Server:
smtp.office365.com - SMTP Port:
587 - Enable SSL:
y - SMTP Username:
notifications@yourdomain.com - From Email Address:
notifications@yourdomain.com
- SMTP Server:
When prompted "Enable OAuth SMTP authentication? (y/n)", answer
yProvide OAuth settings:
- OAuth Token Endpoint: Your token endpoint URL from Azure
- OAuth Client ID: Your Application (client) ID
- OAuth Client Secret: Your client secret value
- OAuth Scope:
https://outlook.office365.com/.default(default)
After Installation (Manual Configuration)
If you need to add or update OAuth SMTP after installation:
Stop XMPro services (SM and/or AD)
Edit configuration file:
C:\XMPro\Global-variables.json
Add or update the
smtpsection in the file:
{
"smtp": {
"enabled": true,
"server": "smtp.office365.com",
"port": "587",
"enableSsl": true,
"username": "notifications@yourdomain.com",
"fromAddress": "notifications@yourdomain.com",
"password": "your-smtp-password",
"oauth": {
"enabled": true,
"tokenEndpoint": "https://login.microsoftonline.com/{tenant-id}/oauth2/v2.0/token",
"clientId": "your-application-client-id",
"clientSecret": "your-client-secret-value",
"scope": "https://outlook.office365.com/.default",
"tokenMethod": "POST",
"grantType": "client_credentials"
}
}
}
- Start XMPro services
Tip
Configuration files are located in C:\XMPro\ by default. The installer preserves these files across reinstalls.
Testing OAuth SMTP Configuration
After configuring OAuth SMTP in your XMPro deployment, verify the configuration is working correctly by triggering an email and checking application logs for successful OAuth token acquisition and delivery.
Quick Check
Use the Forgot Password flow on the Subscription Manager login page to trigger a test email. If the email is received, OAuth SMTP is configured correctly.
App Designer (AD)
Sign in to XMPro App Designer
Create a simple notification (or use an existing one)
Trigger the notification
Verify:
- Email is received
- No errors in application logs
Check Logs
Application logs will show OAuth token acquisition:
Success:
[Information] Successfully acquired OAuth token for SMTP authentication
[Information] Email sent successfully to: user@example.com
Failure:
[Error] Failed to acquire OAuth token: Invalid client secret
[Error] SMTP authentication failed
Troubleshooting
If you encounter issues with OAuth SMTP authentication, this section provides solutions to common problems and guidance on enabling detailed logging for diagnosis. Most issues stem from incorrect Azure AD configuration, expired secrets, or missing Exchange Online permissions. Start by checking the specific error message in your XMPro application logs, then refer to the corresponding solution below.
Common Issues and Solutions
"Insufficient privileges to complete the operation"
Cause: API permissions not granted or admin consent not provided
Solution:
- Go to your Azure AD app registration
- Navigate to API permissions
- Verify SMTP.SendAsApp and Mail.Send are listed
- Ensure status shows "Granted for [Your Organization]"
- If not granted, click Grant admin consent
"Invalid client secret"
Cause: Client secret expired or incorrectly copied
Solution:
- Go to Certificates & secrets in your app registration
- Check if the secret has expired
- Create a new client secret if expired
- Update XMPro configuration with the new secret value
- Restart XMPro services
"AADSTS700016: Application with identifier not found"
Cause: Incorrect tenant ID in token endpoint URL
Solution:
- Verify the tenant ID in your token endpoint URL
- Check it matches the Directory (tenant) ID in Azure AD
- Update the endpoint URL in XMPro configuration
- Restart XMPro services
"AADSTS65001: The user or administrator has not consented"
Cause: Admin consent not granted for application permissions
Solution:
- Have an Azure AD administrator grant admin consent
- Navigate to API permissions > Grant admin consent
- Wait a few minutes for the change to propagate
Emails not sending with OAuth enabled
Possible causes:
- Email notifications not enabled (Terraform):
enable_email_notificationdefaults tofalse. Even with all SMTP and OAuth settings configured, emails will not be sent unlessenable_email_notification = trueis set in yourterraform.tfvars - Email username doesn't match mailbox: Ensure the email username corresponds to a valid Microsoft 365 mailbox
- Mailbox permissions: The Azure AD app needs permission to send from that mailbox
- SMTP AUTH disabled: Ensure SMTP AUTH is enabled for the mailbox in Exchange Online
Solution:
- Verify the email username in XMPro configuration matches a valid mailbox
- Test SMTP connectivity using a tool like Telnet or PowerShell
- Check Exchange Online settings for the mailbox
Enable Detailed Logging
For Windows Server deployments, enable detailed logging:
- Edit
C:\XMPro\Global-variables.json - Add or update:
"LOG_LEVEL": "Debug" - Restart the service
- Check logs in Event Viewer or application log files
For Terraform deployments, set the log level environment variable:
log_level = "Debug"in terraform.tfvars
Security Best Practices
Client Secret Management
Use secure storage:
- Azure Key Vault (for Azure deployments)
- Windows Credential Manager (for Windows Server)
Set expiration reminders:
- Create calendar alerts for secret expiration
- Plan to rotate secrets at least 30 days before expiration
Limit access:
- Restrict who can view/modify client secrets
- Use separate app registrations for dev/test/prod environments
Application Permissions
Principle of least privilege:
- Only grant the required permissions (SMTP.SendAsApp, Mail.Send)
- Don't add additional permissions unless necessary
Regular audits:
- Periodically review app permissions
- Remove unused app registrations
Monitoring
Set up alerts:
- Monitor for SMTP authentication failures
- Alert on approaching secret expiration
Review logs regularly:
- Check for unusual email patterns
- Monitor OAuth token acquisition errors
Migration from Basic Auth
If you're currently using Basic Authentication, follow these steps to migrate:
Before You Begin
- Complete Azure AD app registration (Steps 1-4 above)
- Test OAuth configuration in a non-production environment first
- Document current SMTP settings for rollback if needed
Migration Steps
Update XMPro configuration with OAuth settings (keep existing SMTP settings)
Enable OAuth:
- Set
ENABLE_EMAIL_OAUTH=true(or equivalent for your deployment method)
- Set
Restart XMPro services
Test email functionality:
- Send test emails from SM
- Verify notifications work in AD
- Check logs for OAuth token acquisition
Monitor for 24-48 hours:
- Watch for any email failures
- Review logs for authentication errors
Optional: Remove password from configuration (for security):
- Password is not used when OAuth is enabled
- Can be removed from config files/variables
Rollback Plan
If issues occur after enabling OAuth:
- Set
ENABLE_EMAIL_OAUTH=false - Restart XMPro services
- Verify email works with Basic Auth again
- Investigate the OAuth issue before re-attempting
Note
Keep Basic Auth configured initially as a fallback. Remove it only after OAuth is proven stable.
Additional Resources
- Microsoft Learn: Authenticate SMTP using OAuth
- Exchange Online SMTP AUTH deprecation
- Azure AD app registrations
Need Help?
If you encounter issues not covered in this guide:
- Check XMPro logs for specific error messages
- Review Azure AD app configuration for missing permissions
- Contact XMPro Support with:
- XMPro version
- Deployment method (Terraform, Windows Server)
- Error messages from logs
- Steps already attempted
Last modified: June 11, 2026