Easily view in browser outgoing emails.
masterro/laravel-mail-viewer is a Laravel package for easily view in browser outgoing emails..
It currently has 64 GitHub stars and 117.867 downloads on Packagist (latest version v3.2.1).
Install it with composer require masterro/laravel-mail-viewer.
Discover more Laravel packages by masterro
or browse all Laravel packages to compare alternatives.
Last updated
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.
Run the following command in your terminal:
composer require masterro/laravel-mail-viewer
php artisan mail-viewer:publish
php artisan migrate
Visit /_mail-viewer in your browser to access the email viewer.
Note: The route can be customized in the configuration file.
You can adjust default settings in the config/mail-viewer.php file.
The package supports Laravel's Model Pruning. Define how many days emails should be retained in the configuration:
'prune_older_than_days' => 365,
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.
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.
"extra": {
"laravel": {
"dont-discover": [
"masterro/laravel-mail-viewer"
]
}
},
In your application's ServiceProvider
use MasterRO\MailViewer\Providers\MailViewerServiceProvider;
public function register(): void
{
if (!$this->app->environment('production')) {
$this->app->register(MailViewerServiceProvider::class);
}
}
This package is open-source software licensed under the MIT license.
Developed by MasterRO.