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). Usage Milestone: Google Analytics Module google_analytics crossed 1,000 active installs. Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Release: GraphQL Compose Codegen 1.1.2 Minor update available for module graphql_compose_codegen (1.1.2). Release: Mapy.com 1.1.3 Minor update available for module mapycom (1.1.3). Release: Ckeditor5 entity browser 3.0.3 Minor update available for module ckeditor5_entity_browser (3.0.3). Release: Ckeditor5 entity browser 3.0.1 Minor update available for module ckeditor5_entity_browser (3.0.1). Release: Ckeditor5 entity browser 3.0.2 Minor update available for module ckeditor5_entity_browser (3.0.2). Release: Teamleader Integration 4.0.2 Minor update available for module teamleader (4.0.2). Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

PHPMailer SMTP

12,870 sites Security covered Drupal 11 · not 10
View on drupal.org

This module sends emails via SMTP using the PHPMailer library, supporting HTML emails, attachments, and inline images. It works with the Mail System module and requires an SMTP service for sending messages.

Send emails via SMTP using the latest PHPMailer library.

The only requirements are the Mail System module and an SMTP service.

Features

  • Send email via SMTP using an external service
  • Supports HTML emails, attachments and inline images
  • RFC compliant ensuring robust email delivery
  • Makes extensive use of the widely adopted, battle-tested PHPMailer library
  • Debugging options
  • Advanced SMTP settings

Requirements

  • Access to an SMTP server
  • The Mail System module.
  • PHPMailer library - installed via composer, see below

Installation

composer require drupal/phpmailer_smtp

This installs the module and the PHPMailer library. Enable the module as usual.

If you can't use composer Ludwig is supported.

Configuration

Configure PHPMailer SMTP

SMTP server configuration

Administer -> Configuration -> System -> PHPMailer SMTP

The most secure port is 465 which uses implicit encryption so no part of the communication is in plain text. For this port, select "SSL/TLS" as the encryption protocol.

The "STARTTLS" option is used to upgrade a plain text connection to use TLS. This is used with port 587 which requires an explicit request to change to an encrypted connection and is less secure than the fully encrypted connection on port 465.

Email format

Administer -> Configuration -> System -> PHPMailer SMTP -> Format

Selecting "Plain text" will force all emails to be plain text.

Install and Configure Mail System

composer require drupal/mailsystem

Enable the mail system module then configure:

Administer -> Configuration -> System -> Mail System.

Select "PHPMailer SMTP" as "Sender" under "Default Mail System" and "Module-Specific Configuration" as required.

Select "PHPMailer SMTP" as the Formatter

Security

For better security, SMTP credentials can be stored outside normal config.

  • The simplest option is a local settings.php or settings.local.php which retrieves the credentials from an external service, such as AWS secrets manager. This is more secure than storing them in config, file or environment variables.
  • Key can override any configuration value with a key to store configuration values more securely. See Overriding configuration and key providers supported by the module.
  • Encrypt adds encryption support with a patch for the Key module: #2980072: Encrypt key value

OAuth2

OAuth2 is supported via basic plugins. For an example using Azure, see PHPMailer OAuth2. Review the code in the module to find out how it works so you can implement your own provider.

PHPMailer Azure OAuth2 is a more mature module which integrates with PHPMailer SMTP.

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.

Performance

To improve performance on page load emails can be queued prior to sending.

  • Queue Mail will queue emails which can then be sent later on a cron run.
  • Ultimate Cron allows for fine-grained control over cron runs. For example using Queue Mail, email can be stored and sent sent every minute while other tasks are performed once an hour.

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
10
Tracked since
Jan 2025
Latest release
3 weeks ago
Releases (12 mo)
8 ▲ from 2
Maintenance
Active

Release Timeline

Releases

Version Type Core Release date
3.0.0 Stable 11 Aug 7, 2026
2.4.1 Stable 10–11 Jul 2, 2026
3.0.0-alpha1 Pre-release 11 Jul 2, 2026
3.0.x-dev Dev 11 Jul 2, 2026
2.4.x-dev Dev 10–11 Oct 22, 2025
2.4.0 Stable 10–11 Oct 15, 2025
2.3.1 Stable 10–11 Oct 5, 2025
2.3.0 Stable 10–11 Sep 9, 2025
2.3.0-beta1 Pre-release 10–11 Apr 28, 2025
2.3.x-dev Dev 10–11 Jan 9, 2025