PHPackages                             sinarahmany/laravel-email-monitor - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. sinarahmany/laravel-email-monitor

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

sinarahmany/laravel-email-monitor
=================================

A comprehensive Laravel package to monitor all outgoing emails with tracking, logging, and dashboard capabilities

0.3.0(6mo ago)1193↓50%MITPHPPHP ^8.0

Since Oct 24Pushed 6mo agoCompare

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

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

Laravel Email Monitor
=====================

[](#laravel-email-monitor)

[![Latest Version](https://camo.githubusercontent.com/3fb4be5dc3c1df885e1ba26b96adcd365a07351f276a4a4370e36a07906260a1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d302e312e302d626c75652e737667)](https://github.com/sinarahmany/laravel-email-monitor)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](https://opensource.org/licenses/MIT)[![Laravel](https://camo.githubusercontent.com/b41f9b916485b5a076b4174be55450105ae0ec45a5daa0b7417d85559ca71d8d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d392e7825323025374325323031302e7825323025374325323031312e7825323025374325323031322e782d7265642e737667)](https://laravel.com)

A comprehensive Laravel package to monitor all outgoing emails with tracking, logging, and dashboard capabilities. Built with ❤️ by [Sina Rahmannejad](https://sinarahmannejad.com).

✨ Features
----------

[](#-features)

- 📧 **Automatic Email Tracking**: Monitors all outgoing emails automatically
- 📊 **Dashboard Interface**: Beautiful web interface to view email statistics and logs
- 🔍 **Advanced Filtering**: Filter emails by status, date range, recipient, and more
- 📈 **Statistics &amp; Analytics**: Detailed statistics and analytics for email performance
- 🔄 **Resend Failed Emails**: Easy resending of failed emails
- 🗂️ **Email Details**: View complete email details including body, headers, and metadata
- ⚙️ **Zero Configuration**: Works out-of-the-box with sensible defaults
- 🧹 **Auto Cleanup**: Automatic cleanup of old email logs
- 🔔 **Webhook Support**: Webhook notifications for email status updates
- 🎯 **Status Tracking**: Track sending, sent, delivered, failed, and bounced statuses
- 🚀 **One-Click Setup**: Install and configure with a single command

🚀 Quick Start (One-Click Setup)
-------------------------------

[](#-quick-start-one-click-setup)

### 1. Install the Package

[](#1-install-the-package)

```
composer require sinarahmany/laravel-email-monitor
```

### 2. One-Click Installation

[](#2-one-click-installation)

```
php artisan email-monitor:install
```

That's it! 🎉 The package will automatically:

- ✅ Publish all assets (config, migrations, views)
- ✅ Create the database migration
- ✅ Run migrations automatically
- ✅ Set up routes
- ✅ Configure environment variables
- ✅ Verify installation

### 3. Access the Dashboard

[](#3-access-the-dashboard)

Visit: `http://your-app.com/email-monitor`

### 4. Test Email Monitoring

[](#4-test-email-monitoring)

Visit: `http://your-app.com/test-email` to send a test email and see it in the dashboard

🔧 Alternative Setup Methods
---------------------------

[](#-alternative-setup-methods)

### Quick Setup (Legacy)

[](#quick-setup-legacy)

```
php artisan email-monitor:setup
```

### Force Reinstall

[](#force-reinstall)

```
php artisan email-monitor:install --force
```

### Skip Database Setup

[](#skip-database-setup)

```
php artisan email-monitor:install --skip-migrate
```

📋 Manual Installation (Optional)
--------------------------------

[](#-manual-installation-optional)

If you prefer manual control:

### 1. Install the Package

[](#1-install-the-package-1)

```
composer require sinarahmany/laravel-email-monitor
```

### 2. Publish Configuration

[](#2-publish-configuration)

```
php artisan vendor:publish --tag=email-monitor-config
```

### 3. Publish Migrations

[](#3-publish-migrations)

```
php artisan vendor:publish --tag=email-monitor-migrations
```

### 4. Run Migrations

[](#4-run-migrations)

```
php artisan migrate
```

### 5. Publish Views (Optional)

[](#5-publish-views-optional)

```
php artisan vendor:publish --tag=email-monitor-views
```

⚙️ Configuration (Optional)
---------------------------

[](#️-configuration-optional)

The package works out-of-the-box with sensible defaults. All configuration is optional!

### Environment Variables (Optional)

[](#environment-variables-optional)

Add these variables to your `.env` file only if you want to customize:

```
# Enable/disable email monitoring (default: true)
EMAIL_MONITOR_ENABLED=true

# Database connection (optional, uses default if not set)
EMAIL_MONITOR_CONNECTION=mysql

# Log email body content (default: true)
EMAIL_MONITOR_LOG_BODY=true

# Log metadata (user_id, ip_address, etc.) (default: true)
EMAIL_MONITOR_LOG_METADATA=true

# Auto cleanup old logs after X days (default: 90)
EMAIL_MONITOR_AUTO_CLEANUP_DAYS=90

# Stuck email timeout in minutes (default: 2)
EMAIL_MONITOR_TIMEOUT_MINUTES=2

# Webhook configuration (optional)
EMAIL_MONITOR_WEBHOOKS_ENABLED=false
EMAIL_MONITOR_WEBHOOK_URL=
EMAIL_MONITOR_WEBHOOK_SECRET=

# Notification configuration (optional)
EMAIL_MONITOR_NOTIFICATIONS_ENABLED=false
EMAIL_MONITOR_FAILED_THRESHOLD=5
```

### Configuration File

[](#configuration-file)

The package includes a comprehensive configuration file at `config/email-monitor.php` with the following options:

- **enabled**: Enable/disable email monitoring
- **connection**: Database connection to use
- **table**: Table name for email logs
- **log\_body**: Whether to log email body content
- **log\_metadata**: Whether to log additional metadata
- **route\_prefix**: Dashboard route prefix
- **middleware**: Middleware for dashboard routes
- **auto\_cleanup\_days**: Auto cleanup configuration
- **track\_statuses**: Which statuses to track
- **webhooks**: Webhook configuration
- **filters**: Email filtering options
- **notifications**: Notification settings

Usage
-----

[](#usage)

### Dashboard Access

[](#dashboard-access)

Once installed, you can access the email monitor dashboard at:

```
http://your-app.com/email-monitor

```

### API Endpoints

[](#api-endpoints)

The package provides several API endpoints:

- `GET /email-monitor/api/statistics` - Get email statistics
- `GET /email-monitor/api/recent` - Get recent email logs

### Programmatic Access

[](#programmatic-access)

You can also access email logs programmatically:

```
use Laravel\EmailMonitor\Models\EmailLog;
use Laravel\EmailMonitor\Services\EmailMonitorService;

// Get email logs
$emailLogs = EmailLog::where('status', 'sent')->get();

// Get statistics
$emailMonitorService = app(EmailMonitorService::class);
$statistics = $emailMonitorService->getStatistics(30); // Last 30 days

// Get recent logs
$recentLogs = $emailMonitorService->getRecentLogs(10);
```

### Model Methods

[](#model-methods)

The `EmailLog` model provides several useful methods:

```
// Get formatted status
$emailLog->formatted_status; // "Sent"

// Get status badge class
$emailLog->status_badge_class; // "badge-success"

// Get time since sent
$emailLog->time_since_sent; // "2 hours ago"

// Get recipients as array
$emailLog->recipients; // ['user@example.com', 'admin@example.com']

// Mark as delivered
$emailLog->markAsDelivered();

// Mark as failed
$emailLog->markAsFailed('SMTP timeout');

// Mark as bounced
$emailLog->markAsBounced('Invalid email address');
```

Dashboard Features
------------------

[](#dashboard-features)

### Statistics Overview

[](#statistics-overview)

The dashboard provides comprehensive statistics:

- Total emails sent
- Successfully sent emails
- Pending emails
- Failed emails
- Daily statistics

### Email Logs Table

[](#email-logs-table)

View all email logs with:

- Status badges
- Recipient information
- Sender information
- Subject lines
- Sent timestamps
- Action buttons (view, resend, delete)

### Filtering and Search

[](#filtering-and-search)

- Filter by status (sending, sent, delivered, failed, bounced)
- Search by recipient, sender, or subject
- Date range filtering
- Pagination support

### Email Details

[](#email-details)

View detailed information for each email:

- Complete email headers
- Full email body
- Timing information
- Error messages (if any)
- Metadata (user\_id, ip\_address, etc.)
- Action buttons (resend, delete)

Advanced Features
-----------------

[](#advanced-features)

### Webhook Support

[](#webhook-support)

Configure webhooks to receive real-time notifications:

```
// In your webhook handler
public function handleEmailStatusUpdate($data)
{
    // Handle email status update
    $emailLog = EmailLog::where('message_id', $data['message_id'])->first();

    if ($data['status'] === 'delivered') {
        $emailLog->markAsDelivered();
    } elseif ($data['status'] === 'bounced') {
        $emailLog->markAsBounced($data['reason']);
    }
}
```

### Custom Middleware

[](#custom-middleware)

Add authentication or other middleware to the dashboard:

```
// In config/email-monitor.php
'middleware' => ['web', 'auth', 'admin'],
```

### Email Filtering

[](#email-filtering)

Configure which emails to monitor:

```
// In config/email-monitor.php
'filters' => [
    'exclude_patterns' => [
        'test@example.com',
        '*@test.com',
    ],
    'include_patterns' => [
        // Only monitor emails matching these patterns
    ],
],
```

### Auto Cleanup

[](#auto-cleanup)

Automatically clean up old email logs:

```
// In config/email-monitor.php
'auto_cleanup_days' => 90, // Clean up logs older than 90 days
```

Troubleshooting
---------------

[](#troubleshooting)

### Common Issues

[](#common-issues)

1. **Emails not being logged**: Check if `EMAIL_MONITOR_ENABLED=true` in your `.env` file
2. **Dashboard not accessible**: Ensure the package is properly installed and routes are registered
3. **Database errors**: Make sure migrations have been run

### Debug Mode

[](#debug-mode)

Enable debug mode to see detailed logging:

```
// In config/email-monitor.php
'debug' => env('EMAIL_MONITOR_DEBUG', false),
```

Contributing
------------

[](#contributing)

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

Support
-------

[](#support)

For support, please open an issue on GitHub or contact the maintainers.

Changelog
---------

[](#changelog)

### Version 0.2.0

[](#version-020)

- Initial release
- Basic email monitoring functionality
- Dashboard interface
- Statistics and analytics
- Email filtering and search
- Resend functionality
- Auto cleanup
- Webhook support

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance66

Regular maintenance activity

Popularity16

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 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

Every ~3 days

Total

3

Last Release

200d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2c78045f17c830e800fd0c78068d956aea64a0051cc8c0cca9a88f2195be85ca?d=identicon)[sinarahmany](/maintainers/sinarahmany)

---

Top Contributors

[![sinarahmany](https://avatars.githubusercontent.com/u/46980823?v=4)](https://github.com/sinarahmany "sinarahmany (6 commits)")

---

Tags

laravelloggingemailtrackingdashboardmonitor

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sinarahmany-laravel-email-monitor/health.svg)

```
[![Health](https://phpackages.com/badges/sinarahmany-laravel-email-monitor/health.svg)](https://phpackages.com/packages/sinarahmany-laravel-email-monitor)
```

###  Alternatives

[bugsnag/bugsnag-laravel

Official Bugsnag notifier for Laravel applications.

90334.6M36](/packages/bugsnag-bugsnag-laravel)[masterro/laravel-mail-viewer

Easily view in browser outgoing emails.

6392.1k](/packages/masterro-laravel-mail-viewer)[shaffe/laravel-mail-log-channel

A package to support logging via email in Laravel

1286.2k](/packages/shaffe-laravel-mail-log-channel)

PHPackages © 2026

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