Mailbox for Laravel: Preview &amp; Test Rendered Email | Mohamed Said       [Skip to content](#main)  [ ![](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png) Mohamed SaidLaravel Backend Engineer ](https://www.msaied.com/public) - [Home](https://www.msaied.com/public)
- [Projects](https://www.msaied.com/public/projects)
- [Articles](https://www.msaied.com/public/articles)
- [Certificates](https://www.msaied.com/public/certificates)
- [About](https://www.msaied.com/public#about)

           [  Contact](https://www.msaied.com/public#contact) Menu 

Menu
----

Close 

 - [HomeStart here](https://www.msaied.com/public)
- [ProjectsCase studies](https://www.msaied.com/public/projects)
- [ArticlesEngineering notes](https://www.msaied.com/public/articles)
- [CertificatesCredentials](https://www.msaied.com/public/certificates)
- [AboutHow I work](https://www.msaied.com/public#about)
- [ContactGet in touch](https://www.msaied.com/public#contact)

  [Start a conversation](https://www.msaied.com/public#contact) [WhatsApp](https://wa.me/201094619204) [Email](mailto:hello@msaied.com) 

 1. [Home](https://www.msaied.com/public)
2. /
3. [Articles](https://www.msaied.com/public/articles)
4. /
5. [Laravel](https://www.msaied.com/public/articles?category=laravel)
6. /
7. Mailbox for Laravel: Preview and Test Rendered Email Without a Separate Mail Service

   [Laravel](https://www.msaied.com/public/articles?category=laravel) [Composer Pacakge](https://www.msaied.com/public/articles?category=composer-pacakge) 

 Mailbox for Laravel: Preview and Test Rendered Email Without a Separate Mail Service
=====================================================================================

 Mailbox for Laravel captures outgoing email and displays it at /mailbox inside your app. Built by Redberry, it provides a local inbox, HTML/text previews, attachment downloads, and a test API for asserting on rendered messages.

 ![](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp) [Mohamed Said](https://www.msaied.com/public#person) Published 30 Sep 2026 · Updated 1 Oct 2026 · 3 min read

ShareCopy linkCopied

 ![Mailbox for Laravel: Preview and Test Rendered Email Without a Separate Mail Service](https://cdn.msaied.com/724/4dd058c33317d4ae56d30142f381b680.png) 

  On this page +1. [What Is Mailbox for Laravel?](#what-is-mailbox-for-laravel)
2. [Installing the Package](#installing-the-package)
3. [Browsing the Local Inbox](#browsing-the-local-inbox)
4. [Asserting on Rendered Messages in Tests](#asserting-on-rendered-messages-in-tests)
5. [Capturing and Delivering at the Same Time](#capturing-and-delivering-at-the-same-time)
6. [Production and Security Considerations](#production-and-security-considerations)
7. [Key Takeaways](#key-takeaways)

 What Is Mailbox for Laravel?
----------------------------

Mailbox for Laravel is a package built by [Redberry](https://redberry.international/mailbox-for-laravel-email-testing/) and maintained by Nika Jorjoliani. It intercepts every outgoing email your application sends and stores it in a local inbox accessible at `/mailbox` — no separate mail service or background process required. It supports Mailables, mail notifications, and `Mail::raw()` messages.

The package requires **PHP 8.3 or later** and is compatible with **Laravel 10 through 13**.

---

Installing the Package
----------------------

Install Mailbox as a dev dependency, run the install command, and set the mailer:

```bash
composer require redberry/mailbox-for-laravel --dev
php artisan mailbox:install

```

```env
MAIL_MAILER=mailbox

```

The install command publishes assets, configuration, and runs the package migrations. By default, captured messages are stored in a dedicated SQLite database at `storage/app/mailbox/mailbox.sqlite`. You can also point it at an existing database connection or use the file store.

> **Staging note:** If your staging environment runs `composer install --no-dev`, install Mailbox as a regular dependency instead.

---

Browsing the Local Inbox
------------------------

Open `/mailbox` in your browser to inspect captured messages. The dashboard lets you:

- Switch between **HTML**, **plain-text**, and **raw** message views
- Preview or download **attachments**
- **Search and filter** by recipient
- See the message list update **without a manual page refresh**

---

Asserting on Rendered Messages in Tests
---------------------------------------

Once an email is captured, the package's test API lets you assert on the fully rendered output — not just the Mailable class. This means you can verify the actual HTML your users will see.

```php
use Redberry\MailboxForLaravel\Facades\Mailbox;

Mailbox::assertSentCount(1);

Mailbox::firstSent()
    ->assertHasSubject('Order Confirmation')
    ->assertHasTo('buyer@example.com')
    ->assertSeeInHtml('Order #12345')
    ->assertHasAttachment('receipt.pdf', 'application/pdf');

```

The optional `InteractsWithMailbox` trait clears captured messages before each test and exposes `$this->mailbox()` as an alternative to the facade. You can also assert on the text body, sender, headers, and attachment count. When a test captures multiple messages, pass a callback to `firstSent()` to select the right one.

---

Capturing and Delivering at the Same Time
-----------------------------------------

With `MAIL_MAILER=mailbox`, messages go to the dashboard only. To also deliver them through a real mailer, use the `MAILBOX_DECORATE` option:

```env
MAIL_MAILER=mailbox
MAILBOX_DECORATE=smtp

```

---

Production and Security Considerations
--------------------------------------

- Mailbox is **disabled by default in production**. If `MAIL_MAILER=mailbox` is set while `MAILBOX_ENABLED=false`, emails will not be sent at all — keep your normal production mailer configured.
- On staging, protect `/mailbox` with authentication and define a restrictive `viewMailbox` gate. Captured messages may contain password reset tokens and personal data.
- Automatic pruning is off by default. Set `MAILBOX_RETENTION_SCHEDULE=true` to enable daily cleanup based on your configured retention period.

---

Key Takeaways
-------------

- Drop-in local inbox at `/mailbox` — no external service needed
- Captures Mailables, mail notifications, and `Mail::raw()` calls
- Stores messages in a dedicated SQLite file by default
- Test API asserts on rendered HTML, recipients, subjects, and attachments
- `MAILBOX_DECORATE` lets you capture *and* deliver through a real mailer
- Disabled in production by default; secure the dashboard on staging
- Automatic message pruning available via `MAILBOX_RETENTION_SCHEDULE=true`

---

For full documentation, configuration options, and the complete testing API, see the [GitHub repository](https://github.com/RedberryProducts/mailbox-for-laravel).

*Source: [Mailbox for Laravel: Preview and Test Rendered Email — Laravel News](https://laravel-news.com/mailbox-for-laravel)*

- [Laravel](https://www.msaied.com/public/articles?search=Laravel)
- [Email Testing](https://www.msaied.com/public/articles?search=Email%20Testing)
- [Laravel Packages](https://www.msaied.com/public/articles?search=Laravel%20Packages)
- [Developer Tools](https://www.msaied.com/public/articles?search=Developer%20Tools)
- [PHP](https://www.msaied.com/public/articles?search=PHP)

 Frequently asked questions 
---------------------------

  Does Mailbox for Laravel require an external mail service like Mailtrap or Mailhog?No. Mailbox for Laravel captures outgoing email internally and displays it at /mailbox inside your application. No separate mail service or background process is needed.

   Can I use Mailbox for Laravel on staging as well as local development?Yes. If your staging environment runs composer install --no-dev, install the package as a regular dependency rather than a dev dependency. Protect the /mailbox route with authentication and a restrictive viewMailbox gate, since captured messages may contain sensitive data like password reset tokens.

   How do I assert on the actual rendered HTML of an email in a Laravel test?After sending an email through the Mailbox mailer, use the Mailbox facade or the InteractsWithMailbox trait. Call Mailbox::firstSent() and chain assertions such as assertSeeInHtml(), assertHasSubject(), assertHasTo(), and assertHasAttachment() to verify the fully rendered output.

   ![Mohamed Said](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp)About the author
----------------

[Mohamed Said](https://www.msaied.com/public#person)Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

[About](https://www.msaied.com/public#about) [GitHub ↗](https://github.com/EG-Mohamed) [LinkedIn ↗](https://www.linkedin.com/in/msaiedm/) [WhatsApp ↗](https://wa.me/201094619204) [Email Address ↗](mailto:hello@msaied.com) [My CV ↗](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)  

   [Previous articleLaravel Release Cycle: Versions, Support Policy, and Dates](https://www.msaied.com/public/articles/laravel-release-cycle-versions-support-policy-and-dates) [Next articleWhat's New in Laravel 13.34: Worker Crash Tracking, Timeout Signals, and More](https://www.msaied.com/public/articles/whats-new-in-laravel-1334-worker-crash-tracking-timeout-signals-and-more)  

   On this page
-------------

1. [What Is Mailbox for Laravel?](#what-is-mailbox-for-laravel)
2. [Installing the Package](#installing-the-package)
3. [Browsing the Local Inbox](#browsing-the-local-inbox)
4. [Asserting on Rendered Messages in Tests](#asserting-on-rendered-messages-in-tests)
5. [Capturing and Delivering at the Same Time](#capturing-and-delivering-at-the-same-time)
6. [Production and Security Considerations](#production-and-security-considerations)
7. [Key Takeaways](#key-takeaways)

 ###  Have a technical challenge?

 Tell me what you’re building. I reply within two working days.

[Start a conversation](https://www.msaied.com/public#contact) 

   Related articles
-----------------

 [ ![](https://cdn.msaied.com/740/cce86edc21eddcbdd2f2454fadaf9c70.png)  · 3 min read### The Pipeline Pattern in Laravel: Custom Pipelines Beyond Middleware

5 Oct 2026 ](https://www.msaied.com/public/articles/the-pipeline-pattern-in-laravel-custom-pipelines-beyond-middleware-1) [ ![](https://cdn.msaied.com/739/2d6897fdcdcf090613f96f72a64b8a78.png)  · 4 min read### MySQL Full-Text Search in Laravel: Indexes, Relevance Scoring, and Boolean Mode

4 Oct 2026 ](https://www.msaied.com/public/articles/mysql-full-text-search-in-laravel-indexes-relevance-scoring-and-boolean-mode) [ ![](https://cdn.msaied.com/738/073696a3fefe18bec825beec5ac658f5.png)  · 4 min read### Laravel Queue Rate-Limited Middleware: Throttling Jobs Without Losing Work

4 Oct 2026 ](https://www.msaied.com/public/articles/laravel-queue-rate-limited-middleware-throttling-jobs-without-losing-work) 

  Have a technical challenge?
----------------------------

Tell me what you’re building. I reply within two working days.

 [Discuss your project ↗](https://www.msaied.com/public#contact) 

  © 2026 Mohamed Said · Built with Laravel, meant to last.Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

 - [Home](https://www.msaied.com/public)
- [Articles](https://www.msaied.com/public/articles)
- [Certificates](https://www.msaied.com/public/certificates)
- [GitHub](https://github.com/EG-Mohamed)
- [LinkedIn](https://www.linkedin.com/in/msaiedm/)
- [WhatsApp](https://wa.me/201094619204)
- [Email Address](mailto:hello@msaied.com)
- [My CV](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)
- [Sitemap](https://www.msaied.com/public/sitemap.xml)
