PHPackages                             esign/laravel-email-whitelisting - 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. esign/laravel-email-whitelisting

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

esign/laravel-email-whitelisting
================================

Whitelist outgoing email

2.1.0(2mo ago)417.7k↓30.9%1MITPHPPHP ^8.1CI passing

Since Sep 7Pushed 2mo ago3 watchersCompare

[ Source](https://github.com/esign/laravel-email-whitelisting)[ Packagist](https://packagist.org/packages/esign/laravel-email-whitelisting)[ Docs](https://github.com/esign/laravel-email-whitelisting)[ RSS](/packages/esign-laravel-email-whitelisting/feed)WikiDiscussions master Synced 1mo ago

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

Whitelist outgoing email
========================

[](#whitelist-outgoing-email)

[![Latest Version on Packagist](https://camo.githubusercontent.com/16740e15b5c14637a9d6543b5c3ca351f79299dfdf32c27eae348366ac7cd87a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f657369676e2f6c61726176656c2d656d61696c2d77686974656c697374696e672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/esign/laravel-email-whitelisting)[![Total Downloads](https://camo.githubusercontent.com/8bdf013487206373829f624502ec2d4c784b0ceabf005f8c7d8cb8a3c1a69e6b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f657369676e2f6c61726176656c2d656d61696c2d77686974656c697374696e672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/esign/laravel-email-whitelisting)[![GitHub Actions](https://github.com/esign/laravel-email-whitelisting/actions/workflows/main.yml/badge.svg)](https://github.com/esign/laravel-email-whitelisting/actions/workflows/main.yml/badge.svg)

This package allows you to whitelist email addresses for outgoing emails. This way you have control over what addresses should be allowed to receive mails. This comes in handy when testing on development / staging environments.

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

[](#installation)

You can install the package via composer:

```
composer require esign/laravel-email-whitelisting
```

Next up, you can publish the configuration file:

```
php artisan vendor:publish --provider="Esign\EmailWhitelisting\EmailWhitelistingServiceProvider" --tag="config"
```

The config file will be published as `config/email-whitelisting.php` with the following contents:

```
return [
    /**
     * This is used to disable or enable the use of this package.
     */
    'enabled' => env('EMAIL_WHITELISTING_ENABLED', false),

    /**
     * This is the driver responsible for providing whitelisted email addresses.
     * It should implement the EmailWhitelistingDriverContract interface.
     */
    'driver' => \Esign\EmailWhitelisting\Drivers\ConfigurationDriver::class,

    /**
     * Enabling this setting will cause all outgoing emails to be sent to the
     * configured email adresses, disregarding if they're present in To, Cc or Bcc.
     * When using the config driver these will be the addresses defined in the 'mail_addresses' config key.
     * When using the database driver these will be the addresses where 'redirect_email' is true.
     */
    'redirecting_enabled' => env('EMAIL_WHITELISTING_REDIRECTING_ENABLED', false),

    /**
     * When using the config driver you can define email addresses in this array.
     */
    'mail_addresses' => [
        // 'john@example.com'
    ],
];
```

Usage
-----

[](#usage)

This package is disabled by default. To enable it you may set the `EMAIL_WHITELISTING_ENABLED` env variable to `true`. It ships with both a `ConfigurationDriver` and `DatabaseDriver` out of the box.

### Config

[](#config)

You may define whitelisted email addresses for the config driver under the `mail_addresses` key.

### Database

[](#database)

In case you want to configure email whitelisting using the database this package comes with a database driver out of the box. Make sure to publish the migration before making use of this driver:

```
php artisan vendor:publish --provider="Esign\EmailWhitelisting\EmailWhitelistingServiceProvider" --tag="migrations"
```

Whitelisted email addresses can be created in the following way:

```
use Esign\EmailWhitelisting\Models\WhitelistedEmailAddress;

WhitelistedEmailAddress::create(['email' => 'john@example.com']);
```

### Redirecting emails

[](#redirecting-emails)

In some cases you might want to redirect all outgoing mail to certain addresses. This can be achieved by setting the env variable `EMAIL_WHITELISTING_REDIRECTING_ENABLED` to true. When using the database driver you may specify to which email addresses outgoing mail will be redirected, by setting the `redirect_email` column value to true. When using the config driver no extra configuration is required. Email addresses defined in the `mail_addresses` will be used.

### Wildcards

[](#wildcards)

In case you need to cover lots of email addresses, this package supports using wildcards. By using an `*` you're able to cover a full domain, e.g. `*@esign.eu`.

### Notes

[](#notes)

- Notifications sent through the `mail` channel will be whitelisted as well.
- When there are no matching whitelisted email addresses found, the email will be cancelled.
- This package will append the original receivers to the subject of the outgoing mail. e.g. `My cool mail subject (To: john@example.com) (Cc: jane@example.com)`.

Events
------

[](#events)

### EmailAddressesSkipped

[](#emailaddressesskipped)

When an outgoing email contains recipients that are not whitelisted and are therefore skipped, the package will dispatch the `Esign\EmailWhitelisting\Events\EmailAddressesSkipped` event.

```
namespace App\Listeners;

use Esign\EmailWhitelisting\Events\EmailAddressesSkipped;
use Illuminate\Support\Facades\Log;

class LogSkippedEmailAddresses
{
    public function handle(EmailAddressesSkipped $event): void
    {
        Log::info('Skipped email addresses while sending email:', [
            'sending_type' => $event->sendingType, // e.g. 'to', 'cc', 'bcc'
            'subject' => $event->messageSendingEvent->message->getSubject(),
            'skipped_email_addresses' => $event->skippedEmailAddresses->implode(', '),
            'original_email_addresses' => $event->originalEmailAddresses->implode(', '),
        ]);
    }
}
```

For information on how to register event listeners, see the [Laravel documentation](https://laravel.com/docs/events#registering-events-and-listeners).

### Testing

[](#testing)

```
composer test
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance87

Actively maintained with recent releases

Popularity32

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 90.9% 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 ~257 days

Recently: every ~277 days

Total

6

Last Release

62d ago

Major Versions

1.3.0 → 2.0.02025-05-18

### Community

Maintainers

![](https://www.gravatar.com/avatar/4599d7a8f6fdb63dd04305a49ae5ec9700b7a6eacdbe3a54f89584d75e34503f?d=identicon)[esign](/maintainers/esign)

---

Top Contributors

[![jordyvanderhaegen](https://avatars.githubusercontent.com/u/24370626?v=4)](https://github.com/jordyvanderhaegen "jordyvanderhaegen (40 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (3 commits)")[![seppeclottemans](https://avatars.githubusercontent.com/u/43611652?v=4)](https://github.com/seppeclottemans "seppeclottemans (1 commits)")

---

Tags

esignemail-whitelisting

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/esign-laravel-email-whitelisting/health.svg)

```
[![Health](https://phpackages.com/badges/esign-laravel-email-whitelisting/health.svg)](https://phpackages.com/packages/esign-laravel-email-whitelisting)
```

###  Alternatives

[fedeisas/laravel-mail-css-inliner

Inline the CSS of your HTML emails using Laravel

5974.6M3](/packages/fedeisas-laravel-mail-css-inliner)[s-ichikawa/laravel-sendgrid-driver

This library adds a 'sendgrid' mail driver to Laravel.

4139.3M1](/packages/s-ichikawa-laravel-sendgrid-driver)[illuminate/notifications

The Illuminate Notifications package.

483.0M967](/packages/illuminate-notifications)[illuminate/mail

The Illuminate Mail package.

5910.1M391](/packages/illuminate-mail)[tzsk/sms

A robust and unified SMS gateway integration package for Laravel, supporting multiple providers.

320244.3k6](/packages/tzsk-sms)[therobfonz/laravel-mandrill-driver

Mandrill Driver for Laravel

773.5M](/packages/therobfonz-laravel-mandrill-driver)

PHPackages © 2026

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