Laravel Message Interceptor
This Laravel package helps to intercept e-mails and sends them to another recipient (or recipients) in a local environment.
Laravel ships with one way of intercepting emails in a local environment. However, this packages gives you a little bit more flexibility, such as whitelisting emails and domains in a local environment, preserving
BCC recipients, etc.
This hopefully helps to make the testing experience in email-centric workflows a little less painful for developers working locally.
$ composer require mozammil/laravel-message-interceptor --dev
Because of package auto-discovery, this should automatically register your
To publish the config file, you should do the following:
$ php artisan vendor:publish
The config file will be copied to
config/message-interceptor.php. It should give you an idea of what's possible with the package.
<?php return [ /** * Whether or not the emails being sent should * be intercepted. */ 'enabled' => env('MESSAGE_INTERCEPTOR_ENABLED', false), /** * The intercepted emails will be sent * to this address instead. If the address * is not send, an exception will be thrown */ 'to' => [ 'address' => env('MESSAGE_INTERCEPTOR_ADDRESS', ''), 'name' => env('MESSAGE_INTERCEPTOR_NAME', '') ], /** * By default, we will clear the recipients that are * cc'ed in the message. If you want to preserve the * cc'ed recipients, set this to true */ 'preserveCc' => env('MESSAGE_INTERCEPTOR_PRESERVE_CC', false), /** * By default, we will clear the recipients that are * bcc'ed in the message. If you want to preserve the * bcc'ed recipients, set this to true */ 'preserveBcc' => env('MESSAGE_INTERCEPTOR_PRESERVE_BCC', false), /** * The following addresses will also be CC'ed * when the email is intercepted and sent. */ 'cc' => , /** * The following addresses will also be BCC'ed * when the email is intercepted and sent. */ 'bcc' => , /** * Whitelisted email recipients. */ 'whitelist' => [ /** * Email addresses in the list below will * not be filtered out */ 'emails' => , /** * Email address matching the domain in * the list below will not be filtered out */ 'domains' =>  ] ];
For the package to work appropriately, it is fundamental that the following is configured in your
.env file. By default, no emails will be intercepted.
Whenever an e-mail is intercepted, a
Mozammil\LaravelMessageInterceptor\Events\MessageIntercepted::class event is also dispatched. You could then retrieve the original underlying
Swift_Message from the event.
Please see CHANGELOG for more information on what has changed recently.
$ composer test
If you discover any security related issues, please email email@example.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.