PHPackages                             modernmcguire/mailspy - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. modernmcguire/mailspy

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

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.

0.6.0(3mo ago)36.5k↓50%1[3 PRs](https://github.com/modernmcguire/mailspy/pulls)MITPHPPHP ^8.1CI passing

Since Feb 29Pushed 3mo ago3 watchersCompare

[ Source](https://github.com/modernmcguire/mailspy)[ Packagist](https://packagist.org/packages/modernmcguire/mailspy)[ Docs](https://github.com/modernmcguire/mailspy)[ GitHub Sponsors](https://github.com/ModernMcGuire)[ RSS](/packages/modernmcguire-mailspy/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (8)Versions (15)Used By (0)

MailSpy
=======

[](#mailspy)

[![Latest Version on Packagist](https://camo.githubusercontent.com/7294de2d194341a492e7d4a15e2fce59bf7a49fe1a7441c70424181810930baa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6f6465726e6d6367756972652f6d61696c7370792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/modernmcguire/mailspy)[![GitHub Tests Action Status](https://camo.githubusercontent.com/08b3625d24d6ba10190c57e853a11468ac988065dc1a06f28a095107484f34d4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d6f6465726e6d6367756972652f6d61696c7370792f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/modernmcguire/mailspy/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/b0598bb06b623853d392dca54a9da6dfe890a726297464b26234f47028a888b7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d6f6465726e6d6367756972652f6d61696c7370792f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/modernmcguire/mailspy/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/879ea3f47dc08ee05843633e51ea785f981a7fd4815a65d48ebeda666819d025/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6f6465726e6d6367756972652f6d61696c7370792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/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.

---

Do you want to fully capture your emails as an alternative to the log driver? Try out [MailThief](https://github.com/modernmcguire/mailthief).

---

Installation
------------

[](#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
-----

[](#usage)

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

Events
------

[](#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
----

[](#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
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Ben Miller](https://github.com/modernben)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance78

Regular maintenance activity

Popularity28

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 70.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~63 days

Recently: every ~89 days

Total

12

Last Release

119d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/71c1ed28974c5a60df0a84f0c98ecf9d9c421e988ce7a9cfd28ae06a500599d9?d=identicon)[modernben](/maintainers/modernben)

---

Top Contributors

[![modernben](https://avatars.githubusercontent.com/u/67608755?v=4)](https://github.com/modernben "modernben (39 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (6 commits)")[![braceyourself](https://avatars.githubusercontent.com/u/13386086?v=4)](https://github.com/braceyourself "braceyourself (5 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")

---

Tags

debuglaravellogginglogsmailretentionloglaravelemailModern McGuiremailspy

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/modernmcguire-mailspy/health.svg)

```
[![Health](https://phpackages.com/badges/modernmcguire-mailspy/health.svg)](https://phpackages.com/packages/modernmcguire-mailspy)
```

###  Alternatives

[spatie/laravel-activitylog

A very simple activity logger to monitor the users of your website or application

5.8k45.4M309](/packages/spatie-laravel-activitylog)[spatie/laravel-health

Monitor the health of a Laravel application

86910.0M83](/packages/spatie-laravel-health)[spatie/laravel-slack-alerts

Send a message to Slack

3212.6M4](/packages/spatie-laravel-slack-alerts)[yadahan/laravel-authentication-log

Laravel Authentication Log provides authentication logger and notification for Laravel.

416632.8k5](/packages/yadahan-laravel-authentication-log)[spatie/laravel-error-share

Share your Laravel errors to Flare

43965.6k3](/packages/spatie-laravel-error-share)[saasscaleup/laravel-log-alarm

Laravel log Alarm help you to set up alarm when errors occur in your system and send you a notification via Slack and email

27025.0k](/packages/saasscaleup-laravel-log-alarm)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
