PHPackages                             filippo-toso/laravel-mailog - 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. filippo-toso/laravel-mailog

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

filippo-toso/laravel-mailog
===========================

Log your emails to the database and view them in a simple web interface

v1.0.11(10mo ago)356MITPHPPHP &gt;=8.1CI failing

Since Feb 25Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/filippotoso/laravel-mailog)[ Packagist](https://packagist.org/packages/filippo-toso/laravel-mailog)[ Docs](https://github.com/filippotoso/laravel-mailog)[ RSS](/packages/filippo-toso-laravel-mailog/feed)WikiDiscussions main Synced 1mo ago

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

Laravel Mailog
==============

[](#laravel-mailog)

This package allows you to store all your application outgoing email into a database and (optionally) view them using the integrated Web UI.

You can use it as a mail transport (no email is delivered) or as an event listener (all emails are delivered normally but also logged into the database).

Why does this exist?
====================

[](#why-does-this-exist)

Maybe you are asking yourself why I built this package when there's the [log driver](https://laravel.com/docs/12.x/mail#log-driver) or services like [Mailtrap](https://mailtrap.io/), etc.

I work with a lot of institutional customers (banks, public bodies, you name it...). These customers are very picky about where their data is stored (ie. Are Mailtrap data centers in the EU? How are they secured? Who has access to them? And the list goes on, and on, and on...). This package offers a self-hosted solution that works perfectly in both test and production environments and meets their stringent requirements.

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

[](#installation)

Install the package using composer:

```
composer require filippo-toso/laravel-mailog
```

If you want/need to customize the configuration (ie. use a different database for the logging, etc.), publish the configuration file and change it accordingly:

```
php artisan vendor:publish --tag="mailog-config"

```

Publish the migrations and change them accordingly:

```
php artisan vendor:publish --tag="mailog-migrations"

```

Then, execute the migrations:

```
php artisan migrate

```

Use it as a Mail Transport
--------------------------

[](#use-it-as-a-mail-transport)

In your `config/mail.php` file add the mailog mailer as shown below.

```
return [

    // ...

    'mailers' => [

        // ...

        'mailog' => [
            'transport' => 'mailog',
        ],

    ],

];
```

Then edit your .env file as follows:

```
MAIL_MAILER=mailog

```

Use it as an Event Listener
---------------------------

[](#use-it-as-an-event-listener)

Just edit the `config/mailog.php` file as follows:

```
'listen' => true,

```

Access the Web UI
-----------------

[](#access-the-web-ui)

If you want to use the built-in web UI, you can register the routes in your `web.php` file. Then you'll be able to access the UI using the `/mailog/messages` url.

```
Route::middleware('auth')->group(function () {

    // ...

    \FilippoToso\LaravelMailog\Support\MailogRoutes::register();
});
```

If you want to customize the UI, you can publish the views as follows:

```
php artisan vendor:publish --tag="mailog-views"

```

You can also override the `FilippoToso\LaravelMailog\Http\Controllers\MessageController` class and change its behaviour. For instance you could add a filter for your tenant:

```
use FilippoToso\LaravelMailog\Http\Controllers\Concerns\IsMailogController;

class MailogMessageController extends Controller
{
    use IsMailogController {
        query as mailogQuery;
    }

    /**
     * The query that filters the messages
     *
     * @param array $filters
     * @return Builder
     */
    protected function query(array $filters) {
        return parent::mailogQuery()
            ->where('tenant_id','=', tenant('id'));
    }
}
```

Then you have to update your routes file to point to the right controller. You can take inspiration from the `FilippoToso\LaravelMailog\Support\Routes::register()` method.

Overriding the Mail Transport behaviour
=======================================

[](#overriding-the-mail-transport-behaviour)

In the `config/mailog.php` file you can specify a class to use as a transport. For instance, you can override the provided `MailogTransport` class and add the support for tenancy as follows:

```
use FilippoToso\LaravelMailog\Transport\MailogTransport;
use Symfony\Component\Mime\Email;

class MailogTransportWithTenant extends MailogTransport
{
    /**
     * Build the message data to be stored in the database
     * You can override this method to add more fields to the message
     *
     * @param $messageId
     * @param Email $converdedEmail
     * @return array
     */
    protected function messageData(string $messageId, Email $converdedEmail)
    {
        return array_merge(parent::messageData($messageId, $converdedEmail),[
            'tenant_id' => tenant('id'),
        ]);
    }
}
```

Please beware, the use of `tenant('id')` for identifing the tenant foreign key is just an example taken from the `stancl/tenancy` package. Depending on how you are implementing the tenancy, you should adapt the code as needed.

Other useful things to know
---------------------------

[](#other-useful-things-to-know)

The package includes a `mailog:purge-messages` command. You can schedule it in the scheduler and configure its behaviour in the `purge` section of the `config/mailog.php` file

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance55

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~13 days

Recently: every ~28 days

Total

12

Last Release

300d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/55d89f2d44fb12225de2119994028ee69e36770bcf33c2b1ddf0d6672d28151b?d=identicon)[filippo.toso](/maintainers/filippo.toso)

---

Top Contributors

[![filippotoso](https://avatars.githubusercontent.com/u/26958813?v=4)](https://github.com/filippotoso "filippotoso (15 commits)")

---

Tags

filippotosolaravel-mailog

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/filippo-toso-laravel-mailog/health.svg)

```
[![Health](https://phpackages.com/badges/filippo-toso-laravel-mailog/health.svg)](https://phpackages.com/packages/filippo-toso-laravel-mailog)
```

###  Alternatives

[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[spatie/laravel-activitylog

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

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

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k25.9M107](/packages/laravel-cashier)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[yadahan/laravel-authentication-log

Laravel Authentication Log provides authentication logger and notification for Laravel.

416632.8k5](/packages/yadahan-laravel-authentication-log)

PHPackages © 2026

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