Statamic Mailables Viewer: Preview Laravel Emails in the Control Panel
Laravel Composer Pacakge #Statamic #Laravel #Email #Add-on #Developer Tools

Statamic Mailables Viewer: Preview Laravel Emails in the Control Panel

3 min read Mohamed Said Mohamed Said

Stop Hacking Together Email Preview Routes

If you have ever littered web.php with commented-out /preview-email/{email} routes, or sent the same test message to yourself a dozen times just to check a layout tweak, you are not alone. Jack McDade built Mailables Viewer to replace exactly that workflow.

Mailables Viewer is a free Statamic add-on that scans your Laravel application for mailable classes and surfaces them under Utilities → Mailables in the Statamic Control Panel. No extra configuration, no dedicated routes, no fake-data bootstrapping scripts scattered across the codebase.

How It Works

Once installed, the add-on:

  1. Auto-discovers every mailable in app/Mail (and any additional directories you register via the facade).
  2. Generates sample constructor data so each mailable can be instantiated and rendered immediately.
  3. Renders the HTML preview inline, with desktop, tablet, and mobile viewport toggles.

The live data editor lets you modify scalar constructor values — strings, numbers, booleans, and dates — and watch the preview and envelope update in real time. Objects and arrays are displayed read-only to keep things safe.

Inspecting the Envelope

Beyond the rendered HTML, Mailables Viewer exposes the full envelope for each mailable:

  • Subject line
  • Sender address
  • Attachments
  • Blade/Markdown template reference
  • Queue status
  • References to the mailable class within the codebase

This makes it straightforward to audit email configuration without ever leaving the Control Panel.

Sending Test Emails

When you need to verify rendering in a real inbox, the add-on can copy the rendered HTML to the clipboard or dispatch the mailable immediately via sendNow(). Notably, this works even for mailables that are normally queued, so you can test the full email without waiting for a worker.

// Mailables outside app/Mail can be registered like this:
use Statamic\Addons\MailablesViewer\Facades\MailablesViewer;

MailablesViewer::discover('App\\Notifications\\Mail');

Permissions

Access is straightforward:

  • Super users get access automatically.
  • Other roles can be granted the access mailables utility permission through the standard Statamic roles and permissions UI.

Why This Matters for Laravel Developers

Email previewing has always been a friction point in Laravel development. The typical workarounds — preview routes, repeated test sends to Mailtrap or Herd Pro, or browser-sync hacks — all require manual setup and tear-down. Mailables Viewer centralises this entirely inside the CMS UI, which is especially valuable on projects where non-developers (content editors, QA testers) need to verify email copy without touching the codebase.

Key Takeaways

  • Free Statamic add-on that auto-discovers and previews all Laravel mailables in the Control Panel.
  • Live data editor for scalar constructor values with real-time preview updates.
  • Inspect subject, sender, attachments, template, queue status, and codebase references.
  • Send test emails immediately with sendNow(), even for queued mailables.
  • Desktop, tablet, and mobile viewport previews built in.
  • Mailables outside app/Mail can be registered via the add-on's facade.
  • Role-based access control using Statamic's standard permissions system.

Source: Laravel News — Statamic Mailables Viewer Previews Laravel Emails in the Control Panel

Found this useful?

Frequently Asked Questions

3 questions
Q01 Does Mailables Viewer require dedicated preview routes in web.php?
No. The add-on auto-discovers your Laravel mailable classes and renders them directly inside the Statamic Control Panel under Utilities → Mailables, with no preview routes or extra configuration required.
Q02 Can I preview mailables that are stored outside the default app/Mail directory?
Yes. You can register additional directories or namespaces using the add-on's facade, and those mailables will appear alongside the ones discovered in app/Mail.
Q03 How does sending a test email work for queued mailables?
Mailables Viewer uses sendNow() to dispatch the mailable immediately, bypassing the queue. This lets you verify the rendered output in a real inbox without needing a running queue worker.

Continue reading

More Articles

View all