ashishdhakal/mail-sandbox

A Laravel package that intercepts outgoing emails and stores them locally for viewing via an in-app web interface.
6,332 10
Install
composer require ashishdhakal/mail-sandbox
Latest Version:v2.0.0
PHP:^8.1
License:MIT
Last Updated:Apr 29, 2026
Links: GitHub  ·  Packagist
Maintainer: Ashish-Dhakal

Mail Sandbox for Laravel

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+ (PHP 8.4 required for Laravel 13 projects)
  • 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

  1. Install the package via Composer:
composer require ashishdhakal/mail-sandbox
  1. Publish the configuration and migrations (optional):
php artisan vendor:publish --tag=mail-sandbox-config
php artisan vendor:publish --tag=mail-sandbox-migrations
  1. 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

Related Packages

a2zwebltd/laravel-dev-mode

A lightweight Laravel package that lets developers temporarily bypass Gate autho...

1,408 3
frontier-sh/sinkhole-laravel

Laravel mail transport for Sinkhole — a Cloudflare Worker email trap

2,216 0
bpedroza/laravel-mail-assertions

Make assertions on mail in laravel.

4,257 3
benconstable/phpspec-laravel

Test your Laravel applications with PhpSpec

354,747 144
laravel/browser-kit-testing

Provides backwards compatibility for BrowserKit testing in the latest Laravel re...

10,416,555 516