masterro / laravel-mail-viewer
Easily view in browser outgoing emails.
Installs: 84 738
Dependents: 0
Suggesters: 0
Security: 0
Stars: 63
Watchers: 1
Forks: 12
Open Issues: 0
Language:Vue
pkg:composer/masterro/laravel-mail-viewer
Requires
- doctrine/dbal: ^3.5 | ^4.0 | ^5.0
- illuminate/database: ^10.0|^11.0|^12.0
- illuminate/events: ^10.0|^11.0|^12.0
- illuminate/mail: ^10.0|^11.0|^12.0
- illuminate/routing: ^10.0|^11.0|^12.0
- illuminate/support: ^10.0|^11.0|^12.0
- illuminate/view: ^10.0|^11.0|^12.0
- nesbot/carbon: >=2.62.1
- opcodesio/mail-parser: ^0.2.1
Requires (Dev)
- orchestra/testbench: ^7.0|^8.0|^9.0|^10.0
- pestphp/pest: ^3.8
- dev-master
- v3.x-dev
- v3.0.0
- v3.0.0.beta.2
- v3.0.0.beta
- v2.x-dev
- v2.4.0
- v2.3.1
- v2.3.0
- v2.2.2
- v2.2.1
- v2.2.0
- v2.1.0
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.x-dev
- v1.3.4
- v1.3.3
- v1.3.2
- v1.3.1
- v1.2.1
- v1.2.0
- v1.1.1
- v1.1.0
- v1.0.1
- v1.0.0
- v0.1.0
- v0.0.1-alpha5
- v0.0.1-alpha4
- v0.0.1-alpha3
- v0.0.1-alpha2
- v0.0.1-alpha
- dev-dependabot/npm_and_yarn/pbkdf2-3.1.5
- dev-dependabot/npm_and_yarn/multi-c8afcbbcd8
- dev-dependabot/npm_and_yarn/node-forge-1.3.2
- dev-dependabot/npm_and_yarn/cipher-base-1.0.6
- dev-dependabot/npm_and_yarn/sha.js-2.4.12
- dev-dependabot/npm_and_yarn/multi-96c788614a
This package is auto-updated.
Last update: 2026-02-04 00:01:06 UTC
README
Laravel Mail Viewer
Easily log, view, and search outgoing emails directly in your browser.
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.
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
Step 1: Install via Composer
Run the following command in your terminal:
composer require masterro/laravel-mail-viewer
Step 2: Publish Assets & Configurations
php artisan mail-viewer:publish
Step 3: Run Migrations
php artisan migrate
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
You can adjust default settings in the config/mail-viewer.php file.
Data Pruning
The package supports Laravel's Model Pruning. Define how many days emails should be retained in the configuration:
'prune_older_than_days' => 365,
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 package. Alternatively, you can disable the package in production environments.
Restrict Access with Middleware
Modify your config/mail-viewer.php to apply authorization:
'middleware' => ['web', 'can:viewMailLogs'],
Note:
viewMailLogsis just an example ability you can register via Laravel’s Authorization Gate. 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 auto-discovery:
"extra": { "laravel": { "dont-discover": [ "masterro/laravel-mail-viewer" ] } },
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
This package is open-source software licensed under the MIT license.
Credits
Developed by MasterRO.

