xammie/mailbook
Mailbook is a Laravel dev package for previewing and inspecting mailables and email notifications without triggering them in your app. Register mails via a routes file (with DI or closures) and view them at /mailbook.
Mailbook is a Laravel-first package designed to mock and preview email templates (Mailable/Notification classes) without sending them. It integrates seamlessly with Laravel’s mail system (SwiftMailer) and dependency injection, making it a natural fit for Laravel applications.
Key strengths:
ShouldQueue), and localization.Potential conflicts:
ShouldQueue mailables (fixed in v1.8.4).composer require --dev xammie/mailbook) + php artisan mailbook:install.Mailbook::add(WelcomeMail::class)).--dev dependencies)./mailbook) that should be restricted to dev/staging (not production).ShouldQueue) that need special handling?/mailbook be gated (e.g., IP whitelisting, auth middleware)?MailableTestCase) or supplement them?main branch)?composer require --dev xammie/mailbook
php artisan mailbook:install
routes/mailbook.php:
Mailbook::add(WelcomeMail::class);
Mailbook::add(InvoiceNotification::class);
Mailbook::add(fn () => new OrderMail(Order::factory()->create()));
php artisan vendor:publish --tag="mailbook-config"
php artisan vendor:publish --tag="mailbook-views"
database_rollback, locales, send):
'database_rollback' => env('MAILBOOK_ROLLBACK', true),
'locales' => ['en' => 'English', 'nl' => 'Dutch'],
/mailbook in the browser.| Feature | Compatibility | Notes |
|---|---|---|
| Laravel 10–13 | ✅ Fully supported | Tested in CI. |
| PHP 8.1–8.5 | ✅ Supported | PHP 8.4+ recommended. |
| Queued Mailables | ✅ (v1.8.4+) | Requires no extra config. |
| Localization | ✅ | Manual config setup. |
| Database Rollback | ✅ | Opt-in; may conflict with custom DB ops. |
| Custom Mail Drivers | ❌ (Limited) | Assumes SwiftMailer. |
| Non-Eloquent Queries | ⚠️ | Rollback may fail for raw SQL. |
/mailbook to staging/dev environments./mailbook).--dev)./mailbook: Check route registration.| Scenario | Impact | Mitigation |
|---|---|---|
| Mailable class not found | Preview fails silently | Add validation in routes/mailbook.php. |
| Database rollback conflicts | App crashes on preview | Disable rollback or fix queries. |
/mailbook exposed in prod |
Security risk | Restrict route via middleware/IP. |
| Complex email rendering | Slow previews | Optimize mailable logic. |
| Laravel version mismatch | Package breaks | Pin version in composer.json. |
How can I help you explore Laravel packages today?