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.2.0(1mo ago)65108.9k↓53.5%12[2 PRs](https://github.com/MasterRO94/laravel-mail-viewer/pulls)MITVueCI passing

Since Jan 16Pushed 4d 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 3d ago

READMEChangelog (10)Dependencies (33)Versions (54)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

64

—

FairBetter than 99% of packages

Maintenance97

Actively maintained with recent releases

Popularity47

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 76.8% 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

Recently: every ~104 days

Total

37

Last Release

31d 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 (149 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (34 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (5 commits)")[![claude](https://avatars.githubusercontent.com/u/81847?v=4)](https://github.com/claude "claude (2 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

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[laravel/pulse

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

1.7k15.1M132](/packages/laravel-pulse)[laravel/cashier

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

2.6k29.9M147](/packages/laravel-cashier)[flarum/core

Delightfully simple forum software.

201.4M2.3k](/packages/flarum-core)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45444.2k1](/packages/pressbooks-pressbooks)

PHPackages © 2026

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