PHPackages                             masterro/laravel-mail-viewer - 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. masterro/laravel-mail-viewer

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

masterro/laravel-mail-viewer
============================

Easily view in browser outgoing emails.

v3.1.0(2mo ago)6392.1k↓11.3%12[1 PRs](https://github.com/MasterRO94/laravel-mail-viewer/pulls)MITVueCI passing

Since Jan 16Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/MasterRO94/laravel-mail-viewer)[ Packagist](https://packagist.org/packages/masterro/laravel-mail-viewer)[ RSS](/packages/masterro-laravel-mail-viewer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (22)Versions (45)Used By (0)

 [![](https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg)](https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg)

 [ ![Latest Stable Version](https://camo.githubusercontent.com/ccda5b578259bce0de4dd0a731c1253af302052052c8e682d69a9c37a17fef8b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6173746572726f2f6c61726176656c2d6d61696c2d7669657765722e7376673f7374796c653d666c61742d726f756e646564) ](https://packagist.org/packages/masterro/laravel-mail-viewer) [ ![Total Downloads](https://camo.githubusercontent.com/5a452b72a8e0e0660c85a20db80f0547fb918f96b28730c07fa8d18804aec0b8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6173746572726f2f6c61726176656c2d6d61696c2d7669657765722e7376673f7374796c653d666c61742d726f756e646564) ](https://packagist.org/packages/masterro/laravel-mail-viewer) [ ![License](https://camo.githubusercontent.com/3d45ec61811fc08fe600cdb888b1acd2af877d6ea3bc043c2e7ac3f1f09ac625/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f4d6173746572524f39342f6c61726176656c2d6d61696c2d766965776572) ](https://github.com/MasterRO94/laravel-mail-viewer/blob/master/LICENSE)

 [ ![StandWithUkraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg) ](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md)

Laravel Mail Viewer
===================

[](#laravel-mail-viewer)

Easily log, view, and search outgoing emails directly in your browser.

[![Screenshot of Laravel Mail Viewer - Light Mode](./art/v3-light.png "Preview Light")](./art/v3-light.png)[![Screenshot of Laravel Mail Viewer - Dark Mode](./art/v3-dark.png "Preview Dark")](./art/v3-dark.png)

This package logs all outgoing emails to a database and provides a web interface to view them, formatted as they appear in modern email clients like Gmail.

---

- [Laravel Mail Viewer](#laravel-mail-viewer)
    - [Features](#features)
    - [Installation](#installation)
        - [Step 1: Install via Composer](#step-1-install-via-composer)
        - [Step 2: Publish Assets &amp; Configurations](#step-2-publish-assets--configurations)
        - [Step 3: Run Migrations](#step-3-run-migrations)
        - [Step 4: View Emails](#step-4-view-emails)
    - [Configuration](#configuration)
        - [Data Pruning](#data-pruning)
    - [Production Usage](#production-usage)
        - [Restrict Access with Middleware](#restrict-access-with-middleware)
        - [Disable package in production mode](#disable-package-in-production-mode)
            - [Disable auto-discovery:](#disable-auto-discovery)
            - [Register package for non-production environments](#register-package-for-non-production-environments)
    - [License](#license)
    - [Credits](#credits)

Features
--------

[](#features)

- Logs all outgoing emails to the database
- Modern in-browser email viewer
- Searchable UI with auto-refreshing entries
- Configurable route and access protection
- Optional email pruning

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

[](#installation)

### Step 1: Install via Composer

[](#step-1-install-via-composer)

Run the following command in your terminal:

```
composer require masterro/laravel-mail-viewer
```

### Step 2: Publish Assets &amp; Configurations

[](#step-2-publish-assets--configurations)

```
php artisan mail-viewer:publish
```

### Step 3: Run Migrations

[](#step-3-run-migrations)

```
php artisan migrate
```

### Step 4: View Emails

[](#step-4-view-emails)

Visit `/_mail-viewer` in your browser to access the email viewer.

> **Note:** The route can be customized in the configuration file.

---

Configuration
-------------

[](#configuration)

You can adjust default settings in the `config/mail-viewer.php` file.

### Data Pruning

[](#data-pruning)

The package supports Laravel's [Model Pruning](https://laravel.com/docs/eloquent#pruning-models). Define how many days emails should be retained in the configuration:

```
'prune_older_than_days' => 365,
```

---

Production Usage
----------------

[](#production-usage)

By default, the email viewer is publicly accessible. In a production environment, it's highly recommended to restrict access using middleware or something like [Access Screen](https://github.com/MasterRO94/laravel-access-screen) package. Alternatively, you can disable the package in production environments.

### Restrict Access with Middleware

[](#restrict-access-with-middleware)

Modify your `config/mail-viewer.php` to apply authorization:

```
'middleware' => ['web', 'can:viewMailLogs'],
```

> **Note:** `viewMailLogs` is just an example ability you can register via Laravel’s [Authorization Gate](https://laravel.com/docs/authorization#writing-gates). This ability is not included in the package.

You can also limit access by IP address in `App\Http\Middleware\RestrictMailViewerAccess.php`:

```
namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;

class RestrictMailViewerAccess
{
    public function handle(Request $request, Closure $next)
    {
        if (!in_array($request->ip(), ['127.0.0.1', '::1', 'YOUR_ALLOWED_IP'])) {
            abort(403);
        }

        return $next($request);
    }
}
```

Apply it in config:

```
'middleware' => ['web', RestrictMailViewerAccess::class],
```

Now, only authorized users or allowed IPs can access the mail viewer.

---

### Disable package in production mode

[](#disable-package-in-production-mode)

#### Disable auto-discovery:

[](#disable-auto-discovery)

```
"extra": {
  "laravel": {
    "dont-discover": [
      "masterro/laravel-mail-viewer"
    ]
  }
},
```

#### Register package for non-production environments

[](#register-package-for-non-production-environments)

In your application's `ServiceProvider`

```
use MasterRO\MailViewer\Providers\MailViewerServiceProvider;

public function register(): void
{
    if (!$this->app->environment('production')) {
        $this->app->register(MailViewerServiceProvider::class);
    }
}
```

License
-------

[](#license)

This package is open-source software licensed under the [MIT license](LICENSE).

---

Credits
-------

[](#credits)

Developed by [MasterRO](https://github.com/MasterRO94).

###  Health Score

61

—

FairBetter than 99% of packages

Maintenance88

Actively maintained with recent releases

Popularity46

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 78.5% 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 ~85 days

Total

36

Last Release

60d ago

Major Versions

v0.1.0 → v1.0.02019-02-27

v1.x-dev → v2.0.02022-02-17

v2.4.0 → v3.0.0.beta2025-04-04

### Community

Maintainers

![](https://www.gravatar.com/avatar/bcc2e63995db7d04997577b22426f98b9c6b4c569494c91ba552d73c4df427c2?d=identicon)[MasterRO](/maintainers/MasterRO)

---

Top Contributors

[![MasterRO94](https://avatars.githubusercontent.com/u/7365389?v=4)](https://github.com/MasterRO94 "MasterRO94 (139 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (29 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (5 commits)")[![gw1nblayd](https://avatars.githubusercontent.com/u/29452767?v=4)](https://github.com/gw1nblayd "gw1nblayd (2 commits)")[![s-ivaniuk](https://avatars.githubusercontent.com/u/106524577?v=4)](https://github.com/s-ivaniuk "s-ivaniuk (2 commits)")

---

Tags

loglaravelmailmailable

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/masterro-laravel-mail-viewer/health.svg)

```
[![Health](https://phpackages.com/badges/masterro-laravel-mail-viewer/health.svg)](https://phpackages.com/packages/masterro-laravel-mail-viewer)
```

###  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)[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[laravel/cashier-paddle

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

264778.4k3](/packages/laravel-cashier-paddle)

PHPackages © 2026

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