ashishdhakal / mail-sandbox
A Laravel package that intercepts outgoing emails and stores them locally for viewing via an in-app web interface.
Installs: 19
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 0
Forks: 0
Open Issues: 0
Language:Blade
pkg:composer/ashishdhakal/mail-sandbox
Requires
- php: ^8.1
- illuminate/mail: ^10.0 || ^11.0 || ^12.0
- illuminate/support: ^10.0 || ^11.0 || ^12.0
Requires (Dev)
- orchestra/testbench: ^8.0 || ^9.0 || ^10.0
- pestphp/pest: ^2.0 || ^3.0
- pestphp/pest-plugin-laravel: ^2.0 || ^3.0
README
A Laravel package that intercepts outgoing emails and stores them locally for viewing via an in-app web interface. This is extremely useful in development environments – instead of sending real emails, you can capture them and inspect their content in a browser.
Prerequisites
- PHP v8.1+
- Laravel 10+
Features
- Intercepts all outgoing emails.
- Stores emails in a local database.
- Web interface to list and view captured emails.
- Configurable route prefix and middleware.
- Easy to enable/disable via environment variables.
Installation
- Install the package via Composer:
composer require ashishdhakal/mail-sandbox
- Publish the configuration and migrations (optional):
php artisan vendor:publish --tag=mail-sandbox-config php artisan vendor:publish --tag=mail-sandbox-migrations
- Run the migrations:
php artisan migrate
Configuration
You can configure the package in config/mail-sandbox.php:
return [ 'capture_enabled' => env('MAIL_SANDBOX_CAPTURE', config('app.env') !== 'production'), 'ui_enabled' => env('MAIL_SANDBOX_UI', config('app.env') !== 'production'), 'path' => 'mail-sandbox', 'middleware' => ['web'], ];
Configure Mailer
Add the custom driver to your config/mail.php:
'mailers' => [ 'sandbox' => [ 'transport' => 'sandbox', ], ],
Update .env
Update your .env to activate it:
MAIL_MAILER=sandbox
Usage
Once installed and enabled, any email sent by your application will be intercepted and stored.
Accessing the Interface
You can view the intercepted emails at:
/mail-sandbox
For example: http://your-app.test/mail-sandbox or http://localhost:8000/mail-sandbox
Testing
To run the package's test suite, ensure you have installed the dev dependencies and run:
composer test
The tests are powered by Pest.
Credits
- Ashish Dhakal (ashishdhakal433@gmail.com)
