PHPackages                             niclas-van-eyk/laravel-mail-in-the-middle - 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. [Mail &amp; Notifications](/categories/mail)
4. /
5. niclas-van-eyk/laravel-mail-in-the-middle

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

niclas-van-eyk/laravel-mail-in-the-middle
=========================================

Send mails to the filesystem / database and preview them in your browser

v0.5.1(5y ago)41.4k1[1 PRs](https://github.com/NiclasvanEyk/laravel-mail-in-the-middle/pulls)MITTypeScriptPHP &gt;= 7.2CI failing

Since Apr 2Pushed 4y ago1 watchersCompare

[ Source](https://github.com/NiclasvanEyk/laravel-mail-in-the-middle)[ Packagist](https://packagist.org/packages/niclas-van-eyk/laravel-mail-in-the-middle)[ RSS](/packages/niclas-van-eyk-laravel-mail-in-the-middle/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (7)Versions (11)Used By (0)

✉️ Mail in the middle 📯
=======================

[](#️-mail-in-the-middle-)

Preview the mails sent by your applications just like you would with services like [Mailtrap](https://mailtrap.io/). You can also [view the template source and view data of your Mailables](#more-screenshots).

[![](docs/images/content.png)](docs/images/content.png)

 [![Build Status](https://github.com/niclasvaneyk/laravel-mail-in-the-middle/workflows/Tests/badge.svg)](https://github.com/niclasvaneyk/laravel-mail-in-the-middle/actions) [![Total Downloads](https://camo.githubusercontent.com/878dac75789272e2ecd46423f791d7dd64829aef3e094fb2e1a42043748aa482/68747470733a2f2f706f7365722e707567782e6f72672f6e69636c61732d76616e2d65796b2f6c61726176656c2d6d61696c2d696e2d7468652d6d6964646c652f642f746f74616c2e737667)](https://packagist.org/packages/niclas-van-eyk/laravel-mail-in-the-middle) [![Latest Stable Version](https://camo.githubusercontent.com/945833583ffaa3bf6f7db9a9e81d91d61cbdb65c6e4aed02c8a0684247a28385/68747470733a2f2f706f7365722e707567782e6f72672f6e69636c61732d76616e2d65796b2f6c61726176656c2d6d61696c2d696e2d7468652d6d6964646c652f762f737461626c652e737667)](https://packagist.org/packages/niclas-van-eyk/laravel-mail-in-the-middle) [![License](https://camo.githubusercontent.com/0882b74dac099a9d0a1484e5ecaab61515dbf9b9874a4a7af8fabb8dd44ef433/68747470733a2f2f706f7365722e707567782e6f72672f6e69636c61732d76616e2d65796b2f6c61726176656c2d6d61696c2d696e2d7468652d6d6964646c652f6c6963656e73652e737667)](https://packagist.org/packages/niclas-van-eyk/laravel-mail-in-the-middle)

If you send a mail using `Mail::send(new MyMailable())`, the mail will be stored either in your database or on your filesystem. You can then visit `localhost:8000/mails` (or whatever your `APP_URL` is set to), to see the latest mails sent by your system. The UI shows metadata, like subject, sender, recipients, cc, bcc, as well as Laravel-specific information, like [the source of your mail-template](#source) or [the data provided to your template](#view-data).

Setup
-----

[](#setup)

### Installation

[](#installation)

Require the library via composer:

```
composer require niclas-van-eyk/laravel-mail-in-the-middle --dev
```

Add the following entry to the `mailers` array in your `config/mail.php`:

 If you are not seeing a `'mailers'` section in your `config/mail.php` collapse this
 This is probably either because you are using a Laravel version older than the \*required\* 7.2, or you started your project using the older configuration scheme and updated Laravel from there. For the latter case, just set your `'MAIL_DRIVER'` environment variable to `mail-in-the-middle` and you are good to go. ```
// ...

'mailers' => [
    // the standard mailers, the one before this is usually 'array'...

    // This entry needs to be added
    'mail-in-the-middle' => [
        'transport' => 'mail-in-the-middle',
    ],
],

// rest of the configuration...
```

Add / replace the following parts in your `.env`-file:

```
MAIL_MAILER=mail-in-the-middle
```

If you are sending your `Mailable`s via the default `Mailer` (e.g `Mail::to('recipient@company.org')->send(new MyMailable())`) they will now show up in the UI. The UI is available, if `APP_DEBUG` is set to true. Otherwise it can be enabled/disabled by setting the `MAIL_IN_THE_MIDDLE_ENABLED`environment variable or by manually configuring the `'register_routes'`-value of the `config/mail-in-the-middle.php` file.

**WARNING**: Any mails, that are sent using another mailer, e.g. if you explicitly define, that a `Mailable` should be sent through Mailgun using `Mail::mailer('mailgun')->send(new MyMailable())` will be sent out to the recipient. The [official documentation](https://laravel.com/docs/7.x/mail#sending-mail)provides more information.

### Configuration

[](#configuration)

For now, the package ships with two options to store your mails:

- The `filesystem` driver (default) stores the mails on disk
- The `database` driver saves them to a database table

The `filesystem` driver was chosen to be the default storage option, as it just works out of the box. If no `disk` is set, a local folder under `storage/app/mail-in-the-middle` is created and used.

**If a huge amount of mails are sent by your application, you should definitely consider using the `database` driver!** You can configure the driver by setting the `MAIL_IN_THE_MIDDLE_STORAGE_DRIVER` environment variable to one of the options inside the `config/mail-in-the-middle.php`. If you are using the `database` driver, the necessary migrations should be loaded automatically, just make sure you call `php artisan migrate` before you send your first mail.

For all configuration options, like the path under which you can reach the ui, take a look at the [`mail-in-the-middle.php`-config](config/mail-in-the-middle.php), which can be published and adjusted to your `config/`-directory.

### Housekeeping

[](#housekeeping)

As it is more likely that you are more interested in the most recently sent mails, and for example the `filesystem` driver gets more slow the more mails are stored by your system, it is advised to delete old mails from time to time.

This can either be done through the UI using the red *Delete*-button, or by scheduling a command, that runs regularly and cleans up mails, that have passed a certain age. The latter can be done fairly easily if you have [setup scheduling](https://laravel.com/docs/scheduling) by adding the following to your `App\Console\Kernel::schedule`-method:

```
class Kernel extends ConsoleKernel
{
    // ...
    protected function schedule(Schedule $schedule)
    {
        $schedule
            ->command("mitm:clear-mails-older-than 'last week'")
            ->daily();
    }
    // ...
```

Alternatively you can run that command manually from time to time by executing `php artisan mitm:clear-mails-older-than 'one week'` in the shell of your choice.

More Screenshots
----------------

[](#more-screenshots)

### Source

[](#source)

[!["Source" Tab](docs/images/source.png)](docs/images/source.png)

In this tab you can see the contents of your `.blade.php`-view or markdown template. If you have a good idea on how to add syntax highlighting shoot me a dm, because I did not found one for higlightjs or prism (my last idea would be to try using the monaco editor and the [blade-language-extension](https://marketplace.visualstudio.com/items?itemName=cjhowe7.laravel-blade)).

### View Data

[](#view-data)

[!["View Data" Tab](docs/images/view_data.png)](docs/images/view_data.png)

This tab shows the data that was used to render the html of the email as a `var_dump`. If the object is not a scalar value like an integer or a string, you can inspect the properties by collapsing / opening them using the black arrows next to them.

Scope, feature additions and contributing
-----------------------------------------

[](#scope-feature-additions-and-contributing)

The initial use case that sparked the creation of this package was to provide a project manager or tester with the abilityto easily inspect the mails sent by the application, without the risk of actually sending them out to potential users. Additionally, the mails never leave your system.

So if you import your users from a csv file and send them an initial password, you can safely run the importer on your dev or qa system, without accidentally sending out mails to real users.

As this use-case is satisfied, it is unlikely that more advanced features like advanced searching capabilities, multiple inboxes or other forms of access control will be added in the near future. This being said, if you want to contribute such features I am open to any PRs, but it is recommended to [file an issue](https://github.com/NiclasvanEyk/laravel-mail-in-the-middle/issues/new)first with a description of your proposed feature addition to get some feedback.

Known issues
------------

[](#known-issues)

This package does not seem to function correctly if you set `"minimum-stability"` to `"lowest"` on windows. As I have currently no access to a windows machine I cannot reproduce this locally.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.2% 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 ~21 days

Recently: every ~37 days

Total

8

Last Release

2079d ago

PHP version history (2 changes)v0.4.0PHP 7.\*

v0.5.0PHP &gt;= 7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/9ab82eb06e71c1e4ffd35530565c0a705598483a617d240616c7771e4e736533?d=identicon)[NiclasvanEyk](/maintainers/NiclasvanEyk)

---

Top Contributors

[![NiclasvanEyk](https://avatars.githubusercontent.com/u/10284694?v=4)](https://github.com/NiclasvanEyk "NiclasvanEyk (54 commits)")[![ueman](https://avatars.githubusercontent.com/u/1270149?v=4)](https://github.com/ueman "ueman (1 commits)")

---

Tags

emaillaravelphppreview

###  Code Quality

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/niclas-van-eyk-laravel-mail-in-the-middle/health.svg)

```
[![Health](https://phpackages.com/badges/niclas-van-eyk-laravel-mail-in-the-middle/health.svg)](https://phpackages.com/packages/niclas-van-eyk-laravel-mail-in-the-middle)
```

###  Alternatives

[spatie/laravel-failed-job-monitor

Get notified when a queued job fails

1.0k2.6M4](/packages/spatie-laravel-failed-job-monitor)[vemcogroup/laravel-sparkpost-driver

SparkPost driver to use with Laravel 6.x|7.x|8.x|9.x|10.x

421.7M1](/packages/vemcogroup-laravel-sparkpost-driver)[spatie/mailcoach

Self-host Mailcoach

4007.0k](/packages/spatie-mailcoach)[synergitech/laravel-postal

This library integrates Postal with the standard Laravel mail framework.

38107.1k](/packages/synergitech-laravel-postal)[motomedialab/smtp2go

Send emails via API using the first-class email courier SMTP2Go

1316.3k](/packages/motomedialab-smtp2go)

PHPackages © 2026

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