Configure an SMTP Mail Server with OAuth 2.0 (Microsoft Exchange Online)

This article contains a guide to configuring an SMTP mail server with OAuth 2.0.

Requirements

To configure SMTP mail server with OAuth 2.0, you must meet he following requirements:

  • You must be a System Administrator of the PAS server.
  • You must be or collaborate with your company's Microsoft Entra administrator to:
    • Register an application
    • Create a client secret
    • Grant the required permissions
    • Provide the application identifiers
    • Authorize the application to use the designated mailbox
    • Verify SMTP AUTH availability
  • You must set up a designated Exchange Online sender mailbox and an approved From Address.
  • You must obtain the following values from your Microsoft Entra and Microsoft Exchange administrator:
Value to Collect PAS Field Guidance
Application (client) ID Client ID Copy from the Microsoft Entra application registration Overview page.
Directory (tenant) ID Tenant ID

Copy from the Microsoft Entra application registration Overview page.

Use the tenant that hosts the sender mailbox.

Client secret Value Secret Copy the client secret Value, not its Secret ID. Store it securely; the value is shown only when created.
SMTP mailbox address Username Use the Exchange Online mailbox address authorized for SMTP submission.
Sender email address From Address Normally use the same address as Username. A different sender requires the appropriate Exchange authorization.
SMTP hostname and port Host and Port For standard Exchange Online client submission, use smtp.office365.com and port 587.

Step-by-Step Guide

After you obtain the values from your Microsoft Entra and Exchange admin, continue to configure the SMTP server in PAS:

  1. Sign in to PAS with a System Administrator account.
  2. Go to System Admin > Mail Settings.
  3. Select Add Primary Mail Server, Add Backup Mail Server, or Edit for an existing server.
  4. In Server Type, select Exchange Mail Server with OAuth2.
  5. Complete the fields according to the following table:
    FieldValue or Action
    HostEnter smtp.office365.com for standard Exchange Online client submission. Use a DNS hostname, not a hard-coded Microsoft IP address.
    PortEnter 587. The SMTP connection must use STARTTLS with a TLS version supported by Microsoft 365 (TLS 1.2 or later).
    From AddressEnter the email address displayed to recipients. Use the Username mailbox unless Exchange Online permissions authorize a different sender.
    Client IDEnter the application (client) ID copied from Microsoft Entra ID.
    Tenant IDEnter the directory (tenant) ID copied from Microsoft Entra ID.
    SecretEnter the Microsoft Entra application client secret Value. Do not enter a mailbox password or the secret ID.
    Authority URLUse the default value https://login.microsoftonline.com/. Enter the directory identifier in the separate Tenant ID field.
    Scope URLFor Microsoft application-only SMTP authorization, use the documented default https://outlook.office365.com/.default.
    UsernameEnter the SMTP mailbox address. This is the mailbox identity for SMTP submission, not a request for its password.
  6. Use Send Test Mail, when available on the Mail Settings form, to verify the configuration before saving. Send the message to a monitored recipient mailbox. Note any error message returned by PAS.
  7. Select Save Changes to save the configuration.
  8. If backup mail servers are configured, repeat the configuration and test for each backup server.

Troubleshooting

Identify the stage of the failure before changing configuration values. Microsoft Entra token issuance, Exchange Online SMTP authentication, and message delivery are separate operations.

Stage or Message What to Check Recommended Action
PAS test: “Unable to send test email. Check your configuration.” Generic error; no failure stage is identified. Review the available PAS logs or ask Imprivata Support to identify whether the failure occurred during DNS, TLS, token acquisition, SMTP authentication, or delivery.
exchange.credentialsError Client ID, Tenant ID, Secret Value, authority, or secret expiration. Compare the values to the Entra application registration; generate and enter a new secret if the current value has expired or was lost.
exchange.authError / HTTP 403 The responding endpoint and policy decision are not established by the HTTP status alone. Identify the request URL and Microsoft response in logs. Check authorization, permissions, consent, and applicable policies; do not assume every HTTP 403 means an invalid secret.
OAuth error such as invalid_client or invalid_scope Client credentials, tenant, or token request scope. Check the Entra sign-in/token error details. For the app-only SMTP approach, use https://outlook.office365.com/.default.
SMTP 535 5.7.3 Authentication unsuccessful Token accepted for the wrong audience, missing Exchange authorization, SMTP AUTH policy, or incorrect mailbox identity. Verify the app's Exchange authorization, the mailbox address in Username, and the SMTP AUTH settings; correlate SMTP and Entra logs.
SMTP sender error such as 5.7.60 The sender identity is not authorized. Verify From Address; use the authorized mailbox or ask an Exchange administrator to configure the required Send As permission.
Host, port, or From Address validation error Malformed hostname, port outside 1–65535, or invalid email address. Correct the field and use smtp.office365.com with port 587 for standard Exchange Online.
Authority URL or Scope URL validation error Malformed URL or an incompatible value. Use the documented default HTTPS values. Do not change the token endpoint format without a documented need.
Connection timeout or name-resolution error Outbound DNS or firewall access. Check name resolution and outbound TCP 443 to Microsoft Entra and TCP 587 to Exchange Online from the PAS appliance.
STARTTLS or certificate validation error TLS negotiation or certificate trust failure. Verify the SMTP connection negotiates STARTTLS using TLS 1.2 or later and validates the certificate chain. Do not bypass TLS validation to make the test pass.
Test reports success, but the message does not arrive Mail-flow rules, quarantine, forwarding, throttling, or recipient delivery. Review the recipient mailbox and Microsoft Exchange Online message trace; confirm the sender and recipient addresses.
Backup mail server is not used Backup configuration, connectivity, or failover conditions. Test each configured server independently and review failover behavior with Imprivata Support if needed.