PHPackages                             itinerisltd/wp-phpmailer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. itinerisltd/wp-phpmailer

ActiveWordpress-plugin[Mail &amp; Notifications](/categories/mail)

itinerisltd/wp-phpmailer
========================

WP PHPMailer provides a clean and simple way to configure WordPress-bundled PHPMailer library, allowing you to quickly get started sending mail through a local or cloud based service of your choice.

0.3.0(4y ago)6231.6k—0%6[5 issues](https://github.com/ItinerisLtd/wp-phpmailer/issues)[1 PRs](https://github.com/ItinerisLtd/wp-phpmailer/pulls)MITPHPPHP ^7.2|^8.0

Since Apr 24Pushed 3y ago12 watchersCompare

[ Source](https://github.com/ItinerisLtd/wp-phpmailer)[ Packagist](https://packagist.org/packages/itinerisltd/wp-phpmailer)[ Docs](https://github.com/ItinerisLtd/wp-phpmailer)[ RSS](/packages/itinerisltd-wp-phpmailer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (8)Versions (11)Used By (0)

WP PHPMailer
============

[](#wp-phpmailer)

[![CircleCI](https://camo.githubusercontent.com/2c8b136d2bfa75b9753c0cde7d785c264962890a4679b5b66e0954cbeec59b35/68747470733a2f2f636972636c6563692e636f6d2f67682f4974696e657269734c74642f77702d7068706d61696c65722e7376673f7374796c653d737667)](https://circleci.com/gh/ItinerisLtd/wp-phpmailer)[![Packagist Version](https://camo.githubusercontent.com/a62b410af018ef2d7e97da4fdb54d9313d432e24fc8c7ce33df765f546cd927e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6974696e657269736c74642f77702d7068706d61696c65722e7376673f6c6162656c3d72656c65617365267374796c653d666c61742d737175617265)](https://packagist.org/packages/itinerisltd/wp-phpmailer)[![WordPress Plugin Rating](https://camo.githubusercontent.com/c3989bb53a648b62db5698f132b01745016c773a6b9c72047616f30cc76f4164/68747470733a2f2f696d672e736869656c64732e696f2f776f726470726573732f706c7567696e2f726174696e672f77702d7068706d61696c65723f7374796c653d666c61742d737175617265)](https://wordpress.org/plugins/wp-phpmailer)[![PHP from Packagist](https://camo.githubusercontent.com/3049af632e68a780132b7177a6416fffa08cf11903baae97521ca5d3e7d02235/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6974696e657269736c74642f77702d7068706d61696c65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/itinerisltd/wp-phpmailer)[![WordPress Plugin: Tested WP Version](https://camo.githubusercontent.com/6ac8434f1367bda6be14d16dd89cd89e9b781c833fb321c9110fea8fee555e2a/68747470733a2f2f696d672e736869656c64732e696f2f776f726470726573732f706c7567696e2f7465737465642f77702d7068706d61696c65723f7374796c653d666c61742d737175617265)](https://wordpress.org/plugins/wp-phpmailer)[![Packagist Downloads](https://camo.githubusercontent.com/a60c1f648031705d8a851c44d669712e25bd7b6e2afddceb9e8f26172aa11eb7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6974696e657269736c74642f77702d7068706d61696c65722e7376673f6c6162656c3d7061636b6167697374253230646f776e6c6f616473267374796c653d666c61742d737175617265)](https://packagist.org/packages/itinerisltd/wp-phpmailer/stats)[![WordPress Plugin Downloads](https://camo.githubusercontent.com/847ccf23dcd3f05a72b3563b0e7405b6be2269afab7fa26820816fa5d097edad/68747470733a2f2f696d672e736869656c64732e696f2f776f726470726573732f706c7567696e2f64742f77702d7068706d61696c65723f6c6162656c3d77702e6f7267253230646f776e6c6f616473267374796c653d666c61742d737175617265)](https://wordpress.org/plugins/wp-phpmailer/advanced/)[![GitHub License](https://camo.githubusercontent.com/11f0306a946646f8dde4658fd5da82337ab4e27b58df06319bd03a1fdcf97b22/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6974696e657269736c74642f77702d7068706d61696c65722e7376673f7374796c653d666c61742d737175617265)](https://github.com/ItinerisLtd/wp-phpmailer/blob/master/LICENSE)[![Hire Itineris](https://camo.githubusercontent.com/797dba83c3eb23364eccb600c08a5859e28f7cdbeb4d2b3e3c040067943ad07a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f486972652d4974696e657269732d6666363962342e7376673f7374796c653d666c61742d737175617265)](https://www.itineris.co.uk/contact/)[![Twitter Follow @itineris_ltd](https://camo.githubusercontent.com/c6808dadb94ed1d01a91cc31ef6a97d9862b9bd5240ca81f801250ea0bd2ad8f/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f666f6c6c6f772f6974696e657269735f6c74643f7374796c653d666c61742d73717561726526636f6c6f723d316461316632)](https://twitter.com/itineris_ltd)[![Twitter Follow @TangRufus](https://camo.githubusercontent.com/64c804143721582680296b23033be0dc5a144ef604eb7bf94c94f619a83bb71f/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f666f6c6c6f772f54616e6752756675733f7374796c653d666c61742d73717561726526636f6c6f723d316461316632)](https://twitter.com/tangrufus)

[WP PHPMailer](https://github.com/ItinerisLtd/wp-phpmailer) provides a clean and simple way to configure [the WordPress-bundled PHPMailer library](https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-phpmailer.php), allowing you to quickly get started sending mail through a local or cloud based service of your choice.

- [Goal](#goal)
- [Usage](#usage)
    - [Mailhog](#mailhog)
    - [Mailtrap](#mailtrap)
    - [SendGrid](#sendgrid)
- [Custom Driver](#custom-driver)
    - [Step 1. Define Your Driver](#step-1-define-your-driver)
    - [Step 2. Register Your Driver](#step-2-register-your-driver)
    - [Step 3. Define Constants](#step-3-define-constants)
- [Filters](#filters)
    - [`wp_phpmailer_driver`](#wp_phpmailer_driver)
    - [`wp_phpmailer_drivers`](#wp_phpmailer_drivers)
    - [`wp_phpmailer_config_mappings`](#wp_phpmailer_config_mappings)
- [Minimum Requirements](#minimum-requirements)
- [Installation](#installation)
    - [Composer (Recommended)](#composer-recommended)
    - [wordpress.org (WP CLI)](#wordpressorg-wp-cli)
    - [wordpress.org](#wordpressorg)
    - [Build from Source (Not Recommended)](#build-from-source-not-recommended)
- [Common Errors](#common-errors)
    - [`NotFoundException` - `Driver 'xxx' not found, acceptable values are: aaa, bbb, ccc`](#notfoundexception---driver-xxx-not-found-acceptable-values-are-aaa-bbb-ccc)
- [FAQ](#faq)
    - [Where is the settings page?](#where-is-the-settings-page)
    - [Will you add a settings page?](#will-you-add-a-settings-page)
    - [What PHPMailer version bundled?](#what-phpmailer-version-bundled)
    - [Is it a must to use SMTP?](#is-it-a-must-to-use-smtp)
    - [Will you add support for older PHP versions?](#will-you-add-support-for-older-php-versions)
    - [It looks awesome. Where can I find more goodies like this?](#it-looks-awesome-where-can-i-find-more-goodies-like-this)
    - [Where can I give ⭐⭐⭐⭐⭐ reviews?](#where-can-i-give-starstarstarstarstar-reviews)
- [Testing](#testing)
- [Feedback](#feedback)
- [Security](#security)
- [Credits](#credits)
- [License](#license)

Goal
----

[](#goal)

Although WordPress bundles [the PHPMailer library](https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-phpmailer.php) which allow you sending mail through a local or cloud based service of your choice, different cloud based service requires different configuration. Worse still, most services provide multiple ways for setting them up. For instance: which [SendGrid](https://sendgrid.com/) SMTP port provides the highest level of security, `25`, `587`, `2525` or `465`?

[WP PHPMailer](https://github.com/ItinerisLtd/wp-phpmailer) uses [the WordPress-bundled PHPMailer library](https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-phpmailer.php):

- so you offload the responsibility of updating bundled libraries from plugin authors to WordPress core team and contributors
    - at the time of writing, the official SendGrid plugin's [vendor folder](https://github.com/sendgrid/wordpress/tree/master/vendor) hasn't been updated in 2.5 years

[WP PHPMailer](https://github.com/ItinerisLtd/wp-phpmailer) believes in [convention over configuration](https://rubyonrails.org/doctrine/#convention-over-configuration), we pick the best configuration for each service:

- so you don't waste time going through the documents
- so you don't have to figure out which port and protocol to use
- so you don't miss any security configuration, e.g: `SMTPAuth`, `SMTPSecure`, etc
    - unlike [the official Mailgun plugin](https://wordpress.org/plugins/mailgun/), there is no "use secure SMTP" option because nobody should be using insecure options
- so you only have to provide minimum information
    - take SendGrid for example, only SendGrid API key (with "Mail Send" permission only) is required

[WP PHPMailer](https://github.com/ItinerisLtd/wp-phpmailer) believes a plugin should ["do one thing and do it well"](https://en.wikipedia.org/wiki/Unix_philosophy#Do_One_Thing_and_Do_It_Well):

- unlike [the official SendGrid plugin](https://wordpress.org/plugins/sendgrid-email-delivery-simplified/), [WP PHPMailer](https://github.com/ItinerisLtd/wp-phpmailer) doesn't include the subscription widget nor the stats dashboard

Usage
-----

[](#usage)

Pick one driver and define its required constants in `wp-config.php`.

### Mailhog

[](#mailhog)

```
define('WP_PHPMAILER_DRIVER', 'mailhog');
```

### Mailtrap

[](#mailtrap)

```
define('WP_PHPMAILER_DRIVER', 'mailtrap');

define('MAILTRAP_USERNAME', 'your-mailtrap-username');
define('MAILTRAP_PASSWORD', 'your-mailtrap-password');
```

### SendGrid

[](#sendgrid)

```
define('WP_PHPMAILER_DRIVER', 'sendgrid');

define('SENDGRID_API_KEY', 'your-sendgrid-api-key');

// Optional. Useful if you have email authentication configurated.
define('SENDGRID_FROM_ADDRESS', 'you@example.test');
define('SENDGRID_FROM_NAME', 'John Doe');
define('SENDGRID_FROM_AUTO', true);
```

Custom Driver
-------------

[](#custom-driver)

### Step 1. Define Your Driver

[](#step-1-define-your-driver)

```
class MyCustomDriver implements DriverInterface
{
    public static function makeConfig(ConstantRepository $constantRepo): ConfigInterface
    {
        $config = new Config();

        $config->set('auth', true);
        $config->set('host', 'smtp.custom.test');
        $config->set('port', 587);
        $config->set('protocol', 'tls');

        $config->set(
            'username',
            $constantRepo->getRequired('MY_CUSTOM_USERNAME')
        );

        $config->set(
            'password',
            $constantRepo->getRequired('MY_CUSTOM_PASSWORD')
        );

        $config->set(
            'fromAddress',
            $constantRepo->get('MY_CUSTOM_FROM_ADDRESS')
        );
        $config->set(
            'fromName',
            $constantRepo->get('MY_CUSTOM_FROM_NAME')
        );
        $config->set(
            'fromAuto',
            $constantRepo->get('MY_CUSTOM_FROM_AUTO')
        );

        return $config;
    }
}
```

### Step 2. Register Your Driver

[](#step-2-register-your-driver)

```
add_filter('wp_phpmailer_drivers', function (array $drivers): array {
    $drivers['my-custom-driver'] = MyCustomDriver::class;

    return $drivers;
});
```

### Step 3. Define Constants

[](#step-3-define-constants)

```
// wp-config.php

define('WP_PHPMAILER_DRIVER', 'my-custom-driver');

define('MY_CUSTOM_USERNAME', 'xxx');
define('MY_CUSTOM_PASSWORD', 'xxx');

// Optional.
define('MY_CUSTOM_FROM_ADDRESS', 'xxx');
define('MY_CUSTOM_FROM_NAME', 'xxx');
define('MY_CUSTOM_FROM_AUTO', true);
```

Filters
-------

[](#filters)

### `wp_phpmailer_driver`

[](#wp_phpmailer_driver)

`$driver = (string) apply_filters('wp_phpmailer_driver', string $wpPhpmailerDriver))`

Filters the `WP_PHPMAILER_DRIVER` constant.

Parameters:

- $wpPhpmailerDriver
    - (*string*) the value of `WP_PHPMAILER_DRIVER` constant

### `wp_phpmailer_drivers`

[](#wp_phpmailer_drivers)

`$drivers = (array) apply_filters('wp_phpmailer_drivers', array $drivers)`

Filters the available drivers array.

Parameters:

- $drivers
    - (*array*) the available drivers array

Example:

```
add_filter('wp_phpmailer_drivers', function (array $drivers): array {
   $drivers['my-custom-driver'] = MyCustomDriver::class;

   return $drivers;
});
```

### `wp_phpmailer_config_mappings`

[](#wp_phpmailer_config_mappings)

`$mappings = (array) apply_filters('wp_phpmailer_config_mappings', array $mapings)`

Filters the whitelisted PHPMailer configuration (property names) array. 'fromAddress', 'fromName', 'fromAuto' are special. Do not add them in mappings!

Parameters:

- $mapings
    - (*array*) the whitelisted PHPMailer configuration (property names)

Example:

```
add_filter('wp_phpmailer_config_mappings', function (array $mappings): array {
    $mappings['xxx'] = 'yyy';

    return $mappings;
});

// The above filter results in:
add_action( 'phpmailer_init', function (PHPMailer $phpmailer) {
    // $this->config comes from `DriverInterface::makeConfig`.
    $phpmailer->xxx = $this->config->get('yyy');
});
```

Minimum Requirements
--------------------

[](#minimum-requirements)

- PHP v7.2
- WordPress v5.5

Installation
------------

[](#installation)

### Composer (Recommended)

[](#composer-recommended)

```
composer require itinerisltd/wp-phpmailer
```

### wordpress.org (WP CLI)

[](#wordpressorg-wp-cli)

```
wp plugin install wp-phpmailer
```

### wordpress.org

[](#wordpressorg)

Download from Then, install `wp-phpmailer.zip` [as usual](https://codex.wordpress.org/Managing_Plugins#Installing_Plugins).

### Build from Source (Not Recommended)

[](#build-from-source-not-recommended)

```
# Make sure you use the same PHP version as remote servers.
# Building inside docker images is recommended.
php -v

# Checkout source code
git clone https://github.com/ItinerisLtd/wp-phpmailer.git
cd wp-phpmailer
git checkout

# Build the zip file
composer release:build
```

Then, install `release/wp-phpmailer.zip` [as usual](https://codex.wordpress.org/Managing_Plugins#Installing_Plugins).

Common Errors
-------------

[](#common-errors)

### `NotFoundException` - `Driver 'xxx' not found, acceptable values are: aaa, bbb, ccc`

[](#notfoundexception---driver-xxx-not-found-acceptable-values-are-aaa-bbb-ccc)

Reason: Driver is not found or not defined.

Troubleshooting:

- Ensure PHP constant is `WP_PHPMAILER_DRIVER` is correct
- Ensure filter `wp_phpmailer_driver` is functioning correctly

FAQ
---

[](#faq)

### Where is the settings page?

[](#where-is-the-settings-page)

There is no settings page.

All configurations are done by [PHP constants](https://www.php.net/manual/en/language.constants.php) and [WordPress filters](#filters).

### Will you add a settings page?

[](#will-you-add-a-settings-page)

No.

We have seen [countless](https://blog.sucuri.net/2019/03/0day-vulnerability-in-easy-wp-smtp-affects-thousands-of-sites.html) [vulnerabilities](https://www.pluginvulnerabilities.com/2016/04/04/when-full-disclosure-of-a-claimed-wordpress-plugin-vulnerability-leads-to-a-bigger-problem/) [related](https://www.wordfence.com/blog/2019/03/recent-social-warfare-vulnerability-allowed-remote-code-execution/) [to](https://www.wordfence.com/blog/2018/11/privilege-escalation-flaw-in-wp-gdpr-compliance-plugin-exploited-in-the-wild/) user inputs. Mail settings don't change often and should be configured by a developer. Therefore, [WP PHPMailer](https://github.com/ItinerisLtd/wp-phpmailer) decided to use PHP constants instead of storing options in WordPress database.

However, if you must, you can use [filters](#filters) to override this behavior.

### What PHPMailer version bundled?

[](#what-phpmailer-version-bundled)

This plugin reuse [the PHPMailer class bundled with WordPress core](https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-phpmailer.php).

Thus, you have to keep WordPress core up to date to receive security patches.

### Is it a must to use SMTP?

[](#is-it-a-must-to-use-smtp)

No.

While you can make your own non-SMTP drivers, all default drivers are using SMTP. Pull requests are welcomed.

### Will you add support for older PHP versions?

[](#will-you-add-support-for-older-php-versions)

Never! This plugin will only work on [actively supported PHP versions](https://secure.php.net/supported-versions.php).

Don't use it on **end of life** or **security fixes only** PHP versions.

### It looks awesome. Where can I find more goodies like this?

[](#it-looks-awesome-where-can-i-find-more-goodies-like-this)

- Articles on [Itineris' blog](https://www.itineris.co.uk/blog/)
- More projects on [Itineris' GitHub profile](https://github.com/itinerisltd)
- More plugins on [Itineris](https://profiles.wordpress.org/itinerisltd/#content-plugins) and [TangRufus](https://profiles.wordpress.org/tangrufus/#content-plugins) wp.org profiles
- Follow [@itineris\_ltd](https://twitter.com/itineris_ltd) and [@TangRufus](https://twitter.com/tangrufus) on Twitter
- Hire [Itineris](https://www.itineris.co.uk/services/) to build your next awesome site

### Where can I give ⭐⭐⭐⭐⭐ reviews?

[](#where-can-i-give-starstarstarstarstar-reviews)

Thanks! Glad you like it. It's important to let my boss knows somebody is using this project. Please consider:

- leave a 5-star review on [wordpress.org](https://wordpress.org/support/plugin/wp-phpmailer/reviews/)
- tweet something good with mentioning [@itineris\_ltd](https://twitter.com/itineris_ltd) and [@TangRufus](https://twitter.com/tangrufus)
- ⭐ star this [Github repo](https://github.com/ItinerisLtd/wp-phpmailer)
- 👀 watch this [Github repo](https://github.com/ItinerisLtd/wp-phpmailer)
- write blog posts
- submit [pull requests](https://github.com/ItinerisLtd/wp-phpmailer)
- [hire Itineris](https://www.itineris.co.uk/services/)

Testing
-------

[](#testing)

```
composer test
composer phpstan:analyse
composer style:check
```

Pull requests without tests will not be accepted!

Feedback
--------

[](#feedback)

**Please provide feedback!** We want to make this library useful in as many projects as possible. Please submit an [issue](https://github.com/ItinerisLtd/wp-phpmailer/issues/new) and point out what you do and don't like, or fork the project and make suggestions. **No issue is too small.**

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

[WP PHPMailer](https://github.com/ItinerisLtd/wp-phpmailer) is a [Itineris Limited](https://www.itineris.co.uk/) project created by [Tang Rufus](https://typist.tech).

Special thanks to [Brandon](https://log1x.com/) whose [WP SMTP](https://github.com/Log1x/wp-smtp) inspired this project.

Full list of contributors can be found [here](https://github.com/ItinerisLtd/wp-phpmailer/graphs/contributors).

License
-------

[](#license)

[WP PHPMailer](https://github.com/ItinerisLtd/wp-phpmailer) is released under the [MIT License](https://opensource.org/licenses/MIT).

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 86.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~138 days

Recently: every ~195 days

Total

9

Last Release

1478d ago

PHP version history (2 changes)0.1.0PHP ^7.2

0.3.0PHP ^7.2|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/c1b05c8ed4ea3f68173555264d0226d5faeb7f315ed9df91890c351ef576ce72?d=identicon)[TangRufus](/maintainers/TangRufus)

---

Top Contributors

[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (791 commits)")[![tangrufus](https://avatars.githubusercontent.com/u/2259834?v=4)](https://github.com/tangrufus "tangrufus (83 commits)")[![ouun](https://avatars.githubusercontent.com/u/32090713?v=4)](https://github.com/ouun "ouun (12 commits)")[![kodiakhq[bot]](https://avatars.githubusercontent.com/in/29196?v=4)](https://github.com/kodiakhq[bot] "kodiakhq[bot] (10 commits)")[![codepuncher](https://avatars.githubusercontent.com/u/8135396?v=4)](https://github.com/codepuncher "codepuncher (9 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (6 commits)")[![R00tSquared](https://avatars.githubusercontent.com/u/23155585?v=4)](https://github.com/R00tSquared "R00tSquared (5 commits)")[![pgrimaud](https://avatars.githubusercontent.com/u/1866496?v=4)](https://github.com/pgrimaud "pgrimaud (1 commits)")[![danlapteacru](https://avatars.githubusercontent.com/u/6186169?v=4)](https://github.com/danlapteacru "danlapteacru (1 commits)")

---

Tags

mailhogmailtrapoffice365phpmailersendgridsmtpwordpresswordpress-pluginwordpressemailwpsmtpphpmailer

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/itinerisltd-wp-phpmailer/health.svg)

```
[![Health](https://phpackages.com/badges/itinerisltd-wp-phpmailer/health.svg)](https://phpackages.com/packages/itinerisltd-wp-phpmailer)
```

###  Alternatives

[markguinn/silverstripe-email-helpers

Silverstripe extension containing SMTP mailer class and some other classes for HTML emails

3145.4k1](/packages/markguinn-silverstripe-email-helpers)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
