label84/laravel-mailviewer

View mails sent by Laravel in the browser

v3.3.1 2024-06-10 11:38 UTC

This package is auto-updated.

Last update: 2024-10-10 12:24:56 UTC


README

Latest Stable Version MIT Licensed Total Downloads GitHub Workflow Status

Mailviewer enables you to view and filter mail that is sent by your Laravel application in the browser. The Analytics page gives you insight in the amount of mails sent sent by your application grouped by Notification.

MailViewer screenshot

Laravel Support

Limitations

This package tracks mails sent via Laravel's Mailables and Notifications.

Installation

1. Require package

composer require label84/laravel-mailviewer

2. Publish the config file and migration

php artisan vendor:publish --provider="Label84\MailViewer\MailViewerServiceProvider" --tag="config"
php artisan vendor:publish --provider="Label84\MailViewer\MailViewerServiceProvider" --tag="migrations"

2.1 Publish the views (optional)

To change the default views, you can publish them to your application.

php artisan vendor:publish --provider="Label84\MailViewer\MailViewerServiceProvider" --tag="views"

3. Run migrations

Run the migration command.

php artisan migrate

Usage

To preview the mails sent by your application visit: /admin/mailviewer. You can change this url in the config file.

You can add MAILVIEWER_ENABLED=true to your .env file.

Filters

You can filter the mails in the overview with query parameters - example /admin/mailviewer?notification=WelcomeMail.

The 'notification' parameter only requires the class basename (ie. \Illuminate\Auth\Notifications\VerifyEmail = VerifyEmail).

The around parameter show all mails sent around the given time. By default is will show all mails sent 10 minutes before and 10 minutes after the given time. You can customize the number of minutes by adding an additional &d=X parameter where X is the number of minutes.

Analytics

MailViewer Analytics screenshot

To preview the analytics page visit: /admin/mailviewer/analytics. You can change this url in the config file.

On the analytics page you can view the number of mails sent per Notification and the latest time this notification was sent.

Examples

Example #1

View all VerifyEmail mails to info@example.com.

/admin/mailviewer?to=info@example.com&notification=VerifyEmail

Example #2

View all mails sent in the last 2 hours.

/admin/mailviewer?from=2 hours ago

Exclusion list

In the config file you can add an array of Notification classes and an array of email addresses that should be excluded. Those notifications and email addresses won't be saved to the database.

Tests

composer analyse
composer test

License

MIT