New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

modernmcguire/mailspy

MailSpy is a Laravel package that allows you to capture and inspect emails sent by your application. It was created to help with testing and debugging email sending in Laravel applications in addition to getting around low retention log limits in services like MailGun and MailerSend.
10,267 3
Install
composer require modernmcguire/mailspy
Latest Version:0.6.0
PHP:^8.1
Laravel:10 · 11 · 12
License:MIT
Last Updated:Jun 22, 2026
Links: GitHub  ·  Packagist
Maintainer: modernben

MailSpy

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

MailSpy is a Laravel package that allows you to capture and inspect emails sent by your application. It was created to help with testing and debugging email sending in Laravel applications in addition to getting around low retention log limits in services like MailGun and MailerSend.


Do you want to fully capture your emails as an alternative to the log driver? Try out MailThief.


Installation

You can install the package via composer:

composer require modernmcguire/mailspy

You can publish and run the migrations with:

php artisan vendor:publish --tag="mailspy-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="mailspy-config"

Usage

Nothing to do here! Simply install the package and we will start tracking outgoing email saving the results to your database.

Events

MailSpy listens for the MessageSending and MessageSent events. You may register your own event listeners by calling the Mailspy::sending() and Mailspy::sent() methods in a service provider.

use ModernMcGuire\MailSpy\Facades\MailSpy;
use \Illuminate\Mail\Events\MessageSending;
use \Illuminate\Mail\Events\MessageSent;

MailSpy::sending(function (MessageSending $event, Email $email) {
    // Do something with the event
});

MailSpy::sent(function (MessageSent $event, Email $email) {
    // Do something with the event
});

Tags

If you want to tag your emails, you can do so by adding the MailspyTags concern to any of your mailable classes.

use ModernMcGuire\MailSpy\Facades\MailSpy;
use ModernMcGuire\MailSpy\Traits\MailspyTags;

class MarketingPlan extends Mailable implements ShouldQueue
{
    use Queueable;
    use SerializesModels;
    use MailspyTags;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct(
        public Client $client,
    ) {
        //
    }


    public function tags(): array
    {
        return [
            'client' => $this->client->id,
        ];
    }

}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

nsulistiyawan/laravel-log-mail

Laravel 4 packages for sending log error to email

55 0
juniorb2ss/laravel-email-logger

Possible to armazenate all emails send by application in Redis, Database, Elasti...

447 5
oprudkyi/laravel-mail-logger

Enable debugging/logging communication with mail servers for Laravel 5.*

2,205 4
xdroidteam/log-sent-messages

Log sent messages to DB.

39 0
madeitbelgium/laravel-email-domain-validation

PHP Laravel Email domain validator

69,846 19

Version History

Version Released PHP Laravel License
0.6.0 ^8.1 >=10.0 MIT
0.5.0 ^8.1 ^10.0 MIT
0.4.1 ^8.1 ^10.0 MIT
0.4.0 ^8.1 ^10.0 MIT
0.3.0 ^8.1 ^10.0 MIT