mozammil / laravel-message-interceptor
A Laravel package to intercept emails. Particularly useful in development environments
This package's canonical repository appears to be gone and the package has been frozen as a result.
Installs: 6 854
Dependents: 0
Suggesters: 0
Security: 0
Stars: 9
Watchers: 2
Forks: 8
Open Issues: 0
Requires
- php: ^7.0|^8.0
- laravel/framework: ^8.0|^7.0|^6.0|^5.6
Requires (Dev)
- mockery/mockery: ^1.2
- orchestra/testbench: ^6.0|^5.0|^4.0|^3.0
- phpunit/phpunit: ^7.0|^8.0
This package is auto-updated.
Last update: 2022-07-30 22:07:11 UTC
README
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 CC
and BCC
recipients, etc.
This hopefully helps to make the testing experience in email-centric workflows a little less painful for developers working locally.
Install
Via Composer
$ composer require mozammil/laravel-message-interceptor --dev
Because of package auto-discovery, this should automatically register your ServiceProvider
.
Configuration
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.
MESSAGE_INTERCEPTOR_ADDRESS=hello@example.com
MESSAGE_INTERCEPTOR_ENABLED=true
Additional Information
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.
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
$ composer test
Security
If you discover any security related issues, please email hello@moz.im instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.