Drupal is a registered trademark of Dries Buytaert
Release: Leaflet 10.4.11 Minor update available for module leaflet (10.4.11). Release: Session Inspector 1.0.8 Minor update available for module session_inspector (1.0.8). Release: Migrate QA 2.0.4 Minor update available for module migrate_qa (2.0.4). Release: CKEditor Description List 3.0.0 Major update available for module ckeditor_descriptionlist (3.0.0). Release: FlowDrop 2.4.0 Minor update available for module flowdrop (2.4.0). Release: JWT Token Refresh 1.0.4 Minor update available for module jwt_token_refresh (1.0.4). Release: ConReg 1.0.0-beta1 First beta version released for module conreg (1.0.0-beta1). Release: AI Image Studio 1.0.0-beta8 New beta version released for module ai_image_studio (1.0.0-beta8). Usage Milestone: Role Theme Switcher Module role_theme_switcher crossed 1,000 active installs. Module Revived: Decoupled Router 2.0.7 Module decoupled_router updated after 11 months of inactivity (2.0.7).

This module provides secure Microsoft Entra ID (Azure AD) OAuth2 authentication for the PHPMailer SMTP module. It stores client secrets using the Key module and OAuth2 tokens in the State API, ensuring they are never included in exported configuration. Automatic token refreshing and warnings for administrators are also included.

Provides secure Microsoft Entra ID (Azure AD) OAuth2/XOAUTH2 authentication
for the PHPMailer SMTP module.

Client secrets are stored via the Key module
(typically backed by an environment variable), and OAuth2 tokens are stored in the
State API — never in exported configuration.

Features

  • OAuth2 Authorization Code flow with Microsoft Entra ID (Azure AD).
  • Client secret resolved at runtime from the Key module, never written to configuration.
  • Access token and refresh token stored in the Drupal State API (excluded from configuration export).
  • Automatic keep-alive token refresh on cron (every 60 days).
  • Refresh token age monitoring with administrator warnings at 75 days.
  • CSRF-protected authorization callback.
  • Two-step migration wizard from the phpmailer_oauth2 module.

Mandatory Modules

Post-Installation

After installing the module, complete the following steps to configure Microsoft Entra ID (Azure AD) OAuth2 authentication.

  1. Set the client secret.

    Set the PHPMAILER_OAUTH2_CLIENT_SECRET environment variable on your server.
    The included Key entity (phpmailer_azure_oauth2_client_secret) reads the secret automatically.
  2. Configure the module.

    Go to /admin/config/system/phpmailer-azure-oauth2 and enter:
    • Mailbox email address
    • Application (Client) ID
    • Directory (Tenant) ID
    • Client secret Key (leave the default unless you created your own Key)
  3. Authorize with Microsoft Entra ID.

    Click Authorize with Microsoft Entra ID, sign in to your Microsoft account, and grant permission to the application.
    The access token and refresh token are stored securely in the Drupal State API.
  4. Configure PHPMailer SMTP.

    On the PHPMailer SMTP settings page, select
    Azure OAuth2 (Key module + State API) as the SMTP authentication type.

Similar projects

The PHPMailer OAuth2 module also provides Microsoft Entra ID (Azure AD) OAuth2 authentication for PHPMailer SMTP. This module focuses on improving security and long-term reliability.

  • More secure credential storage.
    Client secrets are stored using the
    Key module, and OAuth2 access and refresh tokens are stored in the Drupal State API. This keeps sensitive information out of exported configuration.
  • Automatic token renewal.
    The module refreshes OAuth2 tokens automatically during cron, helping maintain uninterrupted email delivery. It also warns administrators if a refresh token has not been renewed after 75 days.
  • Built-in CSRF protection.
    The OAuth2 authorization process uses the standard state parameter to validate the callback and protect against CSRF attacks.
  • Easy migration.
    If you are already using phpmailer_oauth2, the included two-step migration wizard imports your existing configuration and OAuth2 tokens, so you do not need to authorize the application again.

Activity

Tracked releases
4
Tracked since
Jul 2026
Latest release
1 month ago
Releases (12 mo)
4 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Release date
1.0.0-alpha3 Pre-release Jul 14, 2026
1.0.0-alpha2 Pre-release Jul 13, 2026
1.0.0-alpha1 Pre-release Jul 7, 2026
1.x-dev Dev Jul 7, 2026