PHPackages                             ashutosh1007/smartmailer - 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. [Mail &amp; Notifications](/categories/mail)
4. /
5. ashutosh1007/smartmailer

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

ashutosh1007/smartmailer
========================

Smart Mailer for Laravel to handle dynamic from-address, SMTP rotation, failover, and monitoring.

v1.0.0(1y ago)00MITPHPPHP ^8.1

Since Apr 23Pushed 1y ago1 watchersCompare

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

READMEChangelogDependencies (9)Versions (2)Used By (0)

SmartMailer
===========

[](#smartmailer)

A robust Laravel package for advanced email management with multiple SMTP server support, intelligent failover, and comprehensive monitoring.

[![Latest Version on Packagist](https://camo.githubusercontent.com/30f2cb407e0b0741a181b9a5473f6991793785dbdcdfb6d9ba6d934c5c2c061b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f796f75722d76656e646f722f736d6172742d6d61696c65722e737667)](https://packagist.org/packages/your-vendor/smart-mailer)[![Total Downloads](https://camo.githubusercontent.com/50dd094e1385aa4d2a706bf51251a6d37bcc66b028de1cbdd36d1ff0d4a1f2c3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f796f75722d76656e646f722f736d6172742d6d61696c65722e737667)](https://packagist.org/packages/your-vendor/smart-mailer)[![License](https://camo.githubusercontent.com/012a17cf034b7ff075f5e9419e69f907599a75949ce05bf1dbbdbba9dafc1658/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f796f75722d76656e646f722f736d6172742d6d61696c65722e737667)](https://packagist.org/packages/your-vendor/smart-mailer)

Features
--------

[](#features)

- 🔄 Multiple SMTP Server Management with Rotation Strategies
- 📧 Type-based Email Routing
- 📊 Comprehensive Dashboard
- 🔄 Automatic Failover
- 📝 Detailed Logging
- ⏱️ Queue Integration
- 📈 Real-time Statistics

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

[](#installation)

1. Install the package via Composer:

```
composer require your-vendor/smart-mailer
```

2. Publish the configuration file:

```
php artisan vendor:publish --provider="SmartMailer\SmartMailerServiceProvider" --tag="config"
```

3. Publish and run the migrations:

```
php artisan vendor:publish --provider="SmartMailer\SmartMailerServiceProvider" --tag="migrations"
php artisan migrate
```

4. Publish the views (optional):

```
php artisan vendor:publish --provider="SmartMailer\SmartMailerServiceProvider" --tag="views"
```

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

[](#configuration)

### Basic Configuration (config/smart\_mailer.php)

[](#basic-configuration-configsmart_mailerphp)

```
return [
    'from_addresses' => [
        'marketing' => [
            'name' => 'Marketing Team',
            'address' => 'marketing@example.com',
            'mailer' => 'rotate'
        ],
        'support' => [
            'name' => 'Support Team',
            'address' => 'support@example.com',
            'mailer' => 'smtp2'
        ]
    ],
    'connections' => [
        [
            'name' => 'smtp1',
            'host' => 'smtp1.example.com',
            'port' => 587,
            'encryption' => 'tls',
            'username' => 'user1@example.com',
            'password' => 'secret1'
        ],
        [
            'name' => 'smtp2',
            'host' => 'smtp2.example.com',
            'port' => 587,
            'encryption' => 'tls',
            'username' => 'user2@example.com',
            'password' => 'secret2'
        ]
    ],
    'strategy' => 'round_robin', // or 'random'

    /*
    |--------------------------------------------------------------------------
    | Logging Configuration
    |--------------------------------------------------------------------------
    |
    | Enable or disable standard file logging (using Laravel's Log facade).
    |
    */
    'logging' => [
        'enabled' => env('SMARTMAILER_LOGGING_ENABLED', false),
        'channel' => env('SMARTMAILER_LOG_CHANNEL', null), // null uses default channel
    ],

    /*
    |--------------------------------------------------------------------------
    | Database Logging Configuration
    |--------------------------------------------------------------------------
    |
    | Enable or disable logging email details to the database.
    |
    */
    'database_logging' => [
        'enabled' => env('SMARTMAILER_DB_LOGGING_ENABLED', true),
    ],

    'queue' => [
        // Default queue connection (null means default Laravel connection)
        'connection' => null,

        // Default queue name (null means default queue)
        'name' => null,

        // Queue settings per email type
        'types' => [
            'marketing' => [
                'connection' => 'redis',
                'queue' => 'marketing-emails',
                'timeout' => 120, // Optional job timeout
            ],
            'bulk' => [
                'connection' => 'redis',
                'queue' => 'bulk-emails',
                'timeout' => 300,
            ],
            'support' => [
                'connection' => 'sync', // Use 'sync' for immediate processing
                'queue' => 'high',
            ],
        ],
    ],
];
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
use SmartMailer\Facades\SmartMailer;

// This will automatically queue the WelcomeEmail if it implements ShouldQueue
SmartMailer::to('recipient@example.com')
    ->type('marketing')
    ->send(new WelcomeEmail($user));
```

### Creating a Mailable

[](#creating-a-mailable)

By default, `SmartMailable` extends Laravel's `Mailable` and implements `Illuminate\Contracts\Queue\ShouldQueue`. This means emails created using `SmartMailable` will automatically be pushed to the queue when you call `SmartMailer::send()`. The specific queue connection and name will be determined by the `queue` configuration in `config/smart_mailer.php` based on the email `type`.

```
use SmartMailer\SmartMailable;

class WelcomeEmail extends SmartMailable
{
    protected $user;

    public function __construct($user)
    {
        $this->user = $user;
    }

    public function build()
    {
        // The view data and subject are defined here
        return $this->view('emails.welcome')
                   ->subject('Welcome to Our Platform!');
    }
}
```

### Overriding Queue Settings per Mailable

[](#overriding-queue-settings-per-mailable)

You can override the default queue settings defined in the configuration file directly within your `SmartMailable` class:

```
class MarketingCampaignEmail extends SmartMailable
{
    public function __construct()
    {
        // Override default queue settings for this specific email
        $this->onQueue('special-marketing-queue')
             ->onConnection('sqs')
             ->delay(now()->addMinutes(10));
    }

    // ... build method ...
}
```

SMTP Server Rotation
--------------------

[](#smtp-server-rotation)

### Round-Robin Strategy

[](#round-robin-strategy)

Evenly distributes emails across all configured SMTP servers:

```
'strategy' => 'round_robin'
```

### Random Strategy

[](#random-strategy)

Randomly selects an SMTP server for each email:

```
'strategy' => 'random'
```

### Per-Type Configuration

[](#per-type-configuration)

Configure specific SMTP servers for different email types:

```
'from_addresses' => [
    'marketing' => [
        'mailer' => 'rotate'  // Uses rotation
    ],
    'support' => [
        'mailer' => 'smtp2'   // Uses specific server
    ]
]
```

Dashboard
---------

[](#dashboard)

Access the dashboard at `/smartmailer` (configurable) to:

- Monitor email status
- View SMTP server health
- Check statistics
- Retry failed emails
- Search and filter logs

### Dashboard Features

[](#dashboard-features)

- Real-time email status monitoring
- SMTP server health checks
- Success/failure statistics
- Detailed error logs
- Email retry functionality
- Advanced filtering options

Error Handling
--------------

[](#error-handling)

```
try {
    SmartMailer::to($email)
        ->type('marketing')
        ->send($mailable);
} catch (Exception $e) {
    // Error is automatically logged
    Log::error('Email sending failed: ' . $e->getMessage());
}
```

Events
------

[](#events)

SmartMailer dispatches several events you can listen for:

```
SmartMailer\Events\EmailSent
SmartMailer\Events\EmailFailed
SmartMailer\Events\SmtpServerDown
```

Advanced Usage
--------------

[](#advanced-usage)

### Custom Metadata

[](#custom-metadata)

```
class CustomEmail extends SmartMailable
{
    public function getMetadata()
    {
        return [
            'campaign_id' => '12345',
            'template_version' => '2.0'
        ];
    }
}
```

### Failover Configuration

[](#failover-configuration)

```
'connections' => [
    [
        'name' => 'primary',
        'priority' => 1,
        // ... SMTP configuration
    ],
    [
        'name' => 'backup',
        'priority' => 2,
        // ... SMTP configuration
    ]
]
```

Testing
-------

[](#testing)

```
composer test
```

Security
--------

[](#security)

If you discover any security-related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Your Name](https://github.com/yourusername)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

Support
-------

[](#support)

For support, please contact  or create an issue in our [issue tracker](https://github.com/your-vendor/smart-mailer/issues).

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

[](#contributing)

Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

Changelog
---------

[](#changelog)

Please see [CHANGELOG.md](CHANGELOG.md) for more information on what has changed recently.

Roadmap
-------

[](#roadmap)

- Support for AWS SES
- Enhanced analytics
- API endpoints for external integration
- Template management system
- Spam score checking

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance47

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

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

390d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/60c90dfd50e30f298a2e8faafaede6e56a8abd212681deefc2920e792282f718?d=identicon)[ashutosh1007](/maintainers/ashutosh1007)

---

Top Contributors

[![lbiashutosh](https://avatars.githubusercontent.com/u/269709842?v=4)](https://github.com/lbiashutosh "lbiashutosh (10 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ashutosh1007-smartmailer/health.svg)

```
[![Health](https://phpackages.com/badges/ashutosh1007-smartmailer/health.svg)](https://phpackages.com/packages/ashutosh1007-smartmailer)
```

###  Alternatives

[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k25.9M107](/packages/laravel-cashier)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[laravel/cashier-paddle

Cashier Paddle provides an expressive, fluent interface to Paddle's subscription billing services.

264778.4k3](/packages/laravel-cashier-paddle)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[masterro/laravel-mail-viewer

Easily view in browser outgoing emails.

6392.1k](/packages/masterro-laravel-mail-viewer)

PHPackages © 2026

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