label84 / laravel-mailviewer
View mails sent by Laravel in the browser
Installs: 17 309
Dependents: 0
Suggesters: 0
Security: 0
Stars: 13
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^8.0
- illuminate/auth: ^10.0|^11.0
- illuminate/database: ^10.0|^11.0
- illuminate/routing: ^10.0|^11.0
- illuminate/support: ^10.0|^11.0
Requires (Dev)
- larastan/larastan: ^2.0
- laravel/pint: ^1.14
- orchestra/testbench: ^8.0|^9.0
README
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.
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
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¬ification=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