Mailbox for Laravel: Preview &amp; Test Rendered Email | Mohamed Said        [  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png)   Mohamed Said Laravel Backend Engineer  ](https://www.msaied.com) [ Home ](https://www.msaied.com) [ Projects ](https://www.msaied.com/projects) [ Articles  ](https://www.msaied.com/articles) [ Certificates ](https://www.msaied.com/certificates) [ Contact ](https://www.msaied.com#contact-section) 

       [  ](https://github.com/EG-Mohamed)       

 [ Home ](https://www.msaied.com) [ Projects ](https://www.msaied.com/projects) [ Articles ](https://www.msaied.com/articles) [ Certificates ](https://www.msaied.com/certificates) [ Contact ](https://www.msaied.com#contact-section) 

  [ home ](https://www.msaied.com)    [ articles ](https://www.msaied.com/articles)    Mailbox for Laravel: Preview and Test Rendered Email Without a Separate Mail Service        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)

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

 [  Laravel ](https://www.msaied.com/articles?category=laravel) [  Composer Pacakge ](https://www.msaied.com/articles?category=composer-pacakge)  #Laravel   #Email Testing   #Laravel Packages   #Developer Tools   #PHP  

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

     30 Sep 2026      3 min read    ![Mohamed Said](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp)  Mohamed Said  

       Table of contents

1. [  01   What Is Mailbox for Laravel?  ](#what-is-mailbox-for-laravel)
2. [  02   Installing the Package  ](#installing-the-package)
3. [  03   Browsing the Local Inbox  ](#browsing-the-local-inbox)
4. [  04   Asserting on Rendered Messages in Tests  ](#asserting-on-rendered-messages-in-tests)
5. [  05   Capturing and Delivering at the Same Time  ](#capturing-and-delivering-at-the-same-time)
6. [  06   Production and Security Considerations  ](#production-and-security-considerations)
7. [  07   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)*

 Found this useful?

          [  ](https://twitter.com/intent/tweet?url=https%3A%2F%2Fwww.msaied.com%2Farticles%2Fmailbox-for-laravel-preview-and-test-rendered-email-without-a-separate-mail-service&text=Mailbox+for+Laravel%3A+Preview+and+Test+Rendered+Email+Without+a+Separate+Mail+Service) [  ](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fwww.msaied.com%2Farticles%2Fmailbox-for-laravel-preview-and-test-rendered-email-without-a-separate-mail-service) 

 Frequently Asked Questions 
----------------------------

  3 questions  

     Q01  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. 

      Q02  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. 

      Q03  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. 

  Continue reading

 More Articles 
---------------

 [ View all    ](https://www.msaied.com/articles) 

 [ ![Laravel AI SDK and Laravel MCP Security Fixes: Update Now](https://cdn.msaied.com/722/fbe8df92faa32e9b9cee984a18bd4411.png) security laravel-ai laravel-mcp 

### Laravel AI SDK and Laravel MCP Security Fixes: Update Now

Two security advisories were published for laravel/ai and laravel/mcp on September 30, 2026. Both are fixed—ru...

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

 30 Sep 2026     3 min read  

  Read    

 ](https://www.msaied.com/articles/laravel-ai-sdk-and-laravel-mcp-security-fixes-update-now) [ ![Migrating Pinkary from Laravel Forge to Laravel Cloud: An Engineering Playbook](https://cdn.msaied.com/723/6f9c9010ccb06581b52bcfab81e47dd9.png) Laravel Cloud Laravel Forge MySQL 

### Migrating Pinkary from Laravel Forge to Laravel Cloud: An Engineering Playbook

A code-backed walkthrough of the real issues encountered moving Pinkary from Laravel Forge to Laravel Cloud: S...

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

 30 Sep 2026     5 min read  

  Read    

 ](https://www.msaied.com/articles/migrating-pinkary-from-laravel-forge-to-laravel-cloud-an-engineering-playbook) [ ![PostgreSQL Recursive CTEs in Laravel: Hierarchical Data Without the ORM Gymnastics](https://cdn.msaied.com/720/3e3d256d54dd4036099122e0b035e482.png) laravel postgresql eloquent 

### PostgreSQL Recursive CTEs in Laravel: Hierarchical Data Without the ORM Gymnastics

Recursive CTEs let PostgreSQL walk tree structures in a single query. Learn how to wire them into Laravel's qu...

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

 30 Sep 2026     2 min read  

  Read    

 ](https://www.msaied.com/articles/postgresql-recursive-ctes-in-laravel-hierarchical-data-without-the-orm-gymnastics) 

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

Explore

- [Home](https://www.msaied.com)
- [Projects](https://www.msaied.com/projects)
- [Articles](https://www.msaied.com/articles)
- [Certificates](https://www.msaied.com/certificates)
- [Contact](https://www.msaied.com#contact-section)

Connect

- [   hello@msaied.com ](mailto:hello@msaied.com)
- [   +20 109 461 9204 ](tel:+201094619204)

© 2026 Mohamed Said. All rights reserved.

 [  ](https://github.com/EG-Mohamed) [  ](https://www.linkedin.com/in/msaiedm/) [  ](https://wa.me/201094619204) [  ](mailto:hello@msaied.com) [  ](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)
