Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Release: Opensolr Search 4.5.0 Minor update available for module opensolr_search (4.5.0). Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Usage Milestone: Views Reference Filter Module entityreference_filter crossed 10,000 active installs. Usage Milestone: Dropdown Language Module dropdown_language crossed 10,000 active installs. Usage Milestone: Paragraphs Browser Module paragraphs_browser crossed 10,000 active installs. Usage Milestone: OpenAPI Module openapi crossed 10,000 active installs. Usage Milestone: Decoupled Router Module decoupled_router crossed 10,000 active installs. Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

PHPMailer OAuth2

314 sites No security coverage
View on drupal.org

This module provides basic OAuth2 support for PHPMailer SMTP, currently supporting Azure authentication. It allows you to configure OAuth2 settings and obtain authentication tokens within Drupal to send emails securely.

Looking for new maintainer

See #3365216: PHPMailer OAuth2 Looking for new maintainer.

Overview and configuration

Provides basic OAuth2 support for PHPMailer SMTP.

It currently only supports Azure authentication. Because Microsoft does not support client credentials flow for SMTP (yet), occasional manual updates of the auth and refresh token may be required.

Configuration is at: Config -> System -> PHPMailer OAuth2

Enter your settings and click "Save Configuration". Once it has been saved, click "Get auth token" to get new auth and refresh tokens.

Once enabled, set the Authentication Type within PHPMailer SMTP.

The redirect path to provide to Azure is /phpmailer_oauth2/aad-callback. For example:

https://www.example.com/phpmailer_oauth2/aad-callback

Install with composer.

composer require drupal/phpmailer_oauth2

Other providers

Review the code in the module to find out how it works so you can implement your own provider. This could be a stand-alone module or included within this module.

The PHPMailer library supports league/oauth2-client providers:

As of PHPMailer 6.6.0, the library now accepts anything that implements the OAuthProviderInterface. This includes Google's OAuth classes.

Alternatives

Gmail OAuth2 Client apparently uses OAuth2 Client and integrates with PHPMailer SMTP.

PHPMailer Azure OAuth2 is actively maintained and more feature complete.

Many email services are recommending the use of their APIs instead of SMTP for sending email. The Pantheon hosting platform also recommends this approach.

There are a few modules for specific services.

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
3
Tracked since
Oct 2025
Latest release
10 months ago
Releases (12 mo)
3 ▲ from 0
Maintenance
Slowing

Release Timeline

Releases

Version Type Core Release date
2.0.0-alpha2 Pre-release 10–11 Oct 21, 2025
2.0.0-alpha1 Pre-release 10–11 Oct 21, 2025
2.0.x-dev Dev 10–11 Oct 21, 2025