PHPackages                             proshore/laravel-mailcatch - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. proshore/laravel-mailcatch

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

proshore/laravel-mailcatch
==========================

Package to handle mailbox in laravel

1.0.0(4mo ago)02MITBladePHP ^8.4

Since Jan 7Pushed 4mo agoCompare

[ Source](https://github.com/proshore/laravel-mailcatch)[ Packagist](https://packagist.org/packages/proshore/laravel-mailcatch)[ RSS](/packages/proshore-laravel-mailcatch/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (4)Used By (0)

Laravel MailCatch
=================

[](#laravel-mailcatch)

[![PHPUnit Test](https://github.com/proshore/laravel-mailcatch/actions/workflows/test.yml/badge.svg)](https://github.com/proshore/laravel-mailcatch/actions/workflows/test.yml)[![PHPStan Analyze](https://github.com/proshore/laravel-mailcatch/actions/workflows/analyze.yml/badge.svg)](https://github.com/proshore/laravel-mailcatch/actions/workflows/analyze.yml)

A Laravel package that intercepts and stores all outgoing emails in your database during development and staging. View and manage caught emails through a built-in web interface.

Features
--------

[](#features)

- 📨 Automatically catches all outgoing emails in specified environments
- 🎨 Beautiful web interface to view caught emails
- 🔍 View HTML and text email bodies
- 📧 See all email metadata (subject, from, to, cc, bcc, headers)
- 🗑️ Delete individual emails or clear all at once
- ⚡ Real-time polling for new emails
- 🔒 Environment-based control
- 🎯 Configurable route prefix and middleware

Requirements
------------

[](#requirements)

- PHP &gt;= 8.4
- Laravel &gt;= 11.x

Installation
------------

[](#installation)

### 1. Install via Composer

[](#1-install-via-composer)

```
composer require proshore/laravel-mailcatch
```

### 2. Publish Configuration (Optional)

[](#2-publish-configuration-optional)

```
php artisan vendor:publish --tag=mailcatch-config
```

### 3. Publish and Run Migrations

[](#3-publish-and-run-migrations)

```
php artisan vendor:publish --tag=mailcatch-migrations
php artisan migrate
```

Configuration
-------------

[](#configuration)

The package publishes a `config/mailcatch.php` file with the following options:

```
return [
    // Enable or disable the package
    'enabled' => env('CATCH_MAIL_ENABLED', true),

    // Environments where emails should be caught
    'allowed_environments' => ['local', 'staging'],

    // Route prefix for the mailbox UI
    'route_prefix' => '__mailbox',

    // Middleware applied to mailbox routes
    'middleware' => ['web'],

    // Maximum length for email body (to prevent database bloat)
    'max_body_length' => 500000,

    // Enable real-time polling for new emails
    'enable_polling' => env('CATCH_MAIL_ENABLE_POLLING', true),

    // Polling interval in milliseconds
    'polling_interval' => env('CATCH_MAIL_POLLING_INTERVAL', 10000),
];
```

### Environment Variables

[](#environment-variables)

You can control the package behavior via `.env`:

```
CATCH_MAIL_ENABLED=true
CATCH_MAIL_ENABLE_POLLING=true
CATCH_MAIL_POLLING_INTERVAL=10000
```

Usage
-----

[](#usage)

### Viewing Caught Emails

[](#viewing-caught-emails)

Once installed, visit the mailbox interface in your browser:

```
http://your-app.test/__mailbox

```

The interface will show all caught emails with:

- Email subject
- From/To addresses
- Date/time sent
- Read/unread status

Click on any email to view:

- Full email details
- HTML preview
- Text version
- All headers
- CC and BCC recipients

### Sending Test Emails

[](#sending-test-emails)

The package automatically catches all emails sent in allowed environments:

```
use Illuminate\Support\Facades\Mail;
use App\Mail\WelcomeEmail;

Mail::to('user@example.com')->send(new WelcomeEmail());
```

The package listens to Laravel's `MessageSent` event to catch emails. The actual email will still be sent according to your mail configuration, but a copy will be stored in the database for viewing in the mailbox interface.

### API Endpoints

[](#api-endpoints)

The package provides API endpoints for programmatic access:

- `GET /__mailbox/api/emails` - List all emails
- `GET /__mailbox/api/emails/{id}` - Get specific email
- `POST /__mailbox/api/emails/{id}/read` - Mark email as read
- `DELETE /__mailbox/api/emails/{id}` - Delete specific email
- `DELETE /__mailbox/api/emails` - Delete all emails

### Accessing the Model

[](#accessing-the-model)

You can also interact with caught emails programmatically:

```
use Proshore\MailCatch\Models\CatchedMail;

// Get all emails
$emails = CatchedMail::all();

// Get unread emails
$unread = CatchedMail::whereNull('read_at')->get();

// Find specific email
$email = CatchedMail::find(1);

// Access email properties
echo $email->subject;
echo $email->html_body;
print_r($email->to);
```

Customization
-------------

[](#customization)

### Custom Route Prefix

[](#custom-route-prefix)

Change the route prefix in the config file:

```
'route_prefix' => 'dev/emails',
```

Now access the mailbox at `http://your-app.test/dev/emails`

### Add Authentication

[](#add-authentication)

Protect the mailbox with middleware:

```
'middleware' => ['web', 'auth', 'admin'],
```

### Disable in Production

[](#disable-in-production)

The package only catches emails in specified environments. Make sure production is not in the list:

```
'allowed_environments' => ['local', 'staging'],
```

Testing
-------

[](#testing)

Run the test suite:

```
composer test
```

Run code analysis:

```
composer analyze
```

Format code:

```
composer format
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Credits
-------

[](#credits)

- [Proshore Nepal Pvt Ltd.](https://github.com/proshore)

Contributers ✨
--------------

[](#contributers-)

[![](https://github.com/kundankarna1994.png)](https://github.com/kundankarna1994/)

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance77

Regular maintenance activity

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

123d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d99533504c12d78d96f97288cfbf7d95cfa88e0135401733e9eddb2a96de999f?d=identicon)[proshore](/maintainers/proshore)

---

Top Contributors

[![kundankarna1994](https://avatars.githubusercontent.com/u/52775829?v=4)](https://github.com/kundankarna1994 "kundankarna1994 (8 commits)")

---

Tags

laravelmailboxmailbox in laravel

###  Code Quality

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/proshore-laravel-mailcatch/health.svg)

```
[![Health](https://phpackages.com/badges/proshore-laravel-mailcatch/health.svg)](https://phpackages.com/packages/proshore-laravel-mailcatch)
```

###  Alternatives

[highideas/laravel-users-online

This package will provide an online users management.

203113.2k1](/packages/highideas-laravel-users-online)[stephenjude/filament-blog

Filament Blog Builder

20317.8k](/packages/stephenjude-filament-blog)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[datomatic/nova-detached-actions

A Laravel Nova tool to allow for placing actions in the Nova toolbar detached from the checkbox selection mechanism.

11229.2k](/packages/datomatic-nova-detached-actions)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
