PHPackages                             diego-mascarenhas/emailer - 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. diego-mascarenhas/emailer

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

diego-mascarenhas/emailer
=========================

Professional email marketing package with maximum deliverability.

v2.0.3(8mo ago)00[4 PRs](https://github.com/diego-mascarenhas/emailer/pulls)MITPHPPHP ^8.1CI passing

Since Aug 28Pushed 1mo agoCompare

[ Source](https://github.com/diego-mascarenhas/emailer)[ Packagist](https://packagist.org/packages/diego-mascarenhas/emailer)[ Docs](https://github.com/diego-mascarenhas/emailer)[ GitHub Sponsors](https://github.com/diego-mascarenhas)[ RSS](/packages/diego-mascarenhas-emailer/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (14)Versions (15)Used By (0)

Emailer - Professional Email Marketing Package
==============================================

[](#emailer---professional-email-marketing-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/e41aa0ec075c008cf17ca9d07a332a72e71bde15a04970273dffcb1c22d29e2b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f69646f6e656f2f656d61696c65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/idoneo/emailer)[![GitHub Tests Action Status](https://camo.githubusercontent.com/cb7b87566186cf0750847eb7d648e7e6a4c0b7327903ac660deb6a9d1d61c433/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f69646f6e656f2f656d61696c65722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/idoneo/emailer/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/eec9105dfb316c46a91fd8e3d02300d7c580b6712aaa7ec2bbc907f6e1e1ba0b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f69646f6e656f2f656d61696c65722f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/idoneo/emailer/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/00584c3c8251dce416938ea1dd188b7509909d1c315ee54f866b5a2259837c3c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f69646f6e656f2f656d61696c65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/idoneo/emailer)

Professional email marketing package for Laravel with maximum deliverability, advanced tracking, and multi-provider support.

Features
--------

[](#features)

✨ **Multi-Provider Support**: SMTP, Mailgun, SendGrid, MailBaby with automatic fallback 📊 **Advanced Analytics**: Open rates, click tracking, bounce tracking, and detailed statistics
⚡ **Queue-Based Processing**: Scalable email delivery with configurable delays 🎯 **Team-Based Configuration**: Per-team email settings and branding 📈 **Real-time Tracking**: Pixel tracking for opens and click tracking for links 🔄 **Webhook Integration**: Automatic status updates from email providers 🎨 **Template Support**: Rich HTML templates with variable replacement 📱 **Responsive Design**: Mobile-optimized email templates 🛡️ **Spam Prevention**: Built-in delays and best practices for deliverability

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

[](#installation)

You can install the package via composer:

```
composer require idoneo/emailer
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="emailer-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="emailer-config"
```

This is the contents of the published config file:

```
return [
    'email_provider' => env('EMAILER_PROVIDER', 'smtp'),
    'queue_name' => env('EMAILER_QUEUE', 'emailer'),
    'delays' => [
        'base_minutes' => env('EMAILER_DELAY_BASE_MINUTES', 5),
        'random_seconds' => env('EMAILER_DELAY_RANDOM_SECONDS', 120),
    ],
    // ... more configuration options
];
```

Basic Usage
-----------

[](#basic-usage)

### Creating a Message Campaign

[](#creating-a-message-campaign)

```
use idoneo\Emailer\Models\Message;
use idoneo\Emailer\Models\MessageType;
use idoneo\Emailer\Facades\Emailer;

// Create a message type
$messageType = MessageType::create([
    'name' => 'Newsletter',
    'status' => 1
]);

// Create a message
$message = Message::create([
    'name' => 'Welcome Newsletter',
    'subject' => 'Welcome to our platform!',
    'content' => 'Welcome {{name}}!Thank you for joining us.',
    'type_id' => $messageType->id,
    'team_id' => auth()->user()->currentTeam->id,
    'status_id' => 1
]);

// Start the campaign
Emailer::startCampaign($message);
```

### Sending Test Emails

[](#sending-test-emails)

```
// Send a test email
Emailer::sendTest($message, 'test@example.com', 'Test User');
```

### Getting Campaign Statistics

[](#getting-campaign-statistics)

```
$stats = Emailer::getCampaignStats($message);

echo "Total sent: " . $stats['sent'];
echo "Open rate: " . $stats['open_rate'] . "%";
echo "Click rate: " . $stats['click_rate'] . "%";
```

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

[](#configuration)

### Environment Variables

[](#environment-variables)

Add these variables to your `.env` file:

```
# Email Provider Configuration
EMAILER_PROVIDER=smtp                    # smtp|mailgun|sendgrid|mailbaby
EMAILER_FALLBACK_TO_SMTP=true           # Fallback to SMTP if provider fails

# Queue Configuration
EMAILER_QUEUE=emailer                    # Queue name for email jobs

# Delay Configuration (Anti-spam)
EMAILER_DELAY_BASE_MINUTES=5            # Minutes between emails
EMAILER_DELAY_RANDOM_SECONDS=120        # Random seconds added

# Default Email Settings
EMAILER_FROM_ADDRESS=noreply@example.com
EMAILER_FROM_NAME="Your Company"
EMAILER_REPLY_TO_ADDRESS=support@example.com

# Tracking
EMAILER_TRACKING_ENABLED=true
EMAILER_OPEN_TRACKING=true
EMAILER_CLICK_TRACKING=true

# Provider-specific settings
MAILGUN_DOMAIN=mg.example.com
MAILGUN_SECRET=key-xxxxx

SENDGRID_API_KEY=SG.xxxxx

MAILBABY_API_KEY=xxxxx
MAILBABY_API_URL=https://api.mailbaby.net
```

### Team-Based Configuration

[](#team-based-configuration)

The package supports team-based email configuration. Each team can have its own SMTP settings:

```
// In your Team model, implement these methods:
public function hasOutgoingEmailConfig(): bool
{
    return $this->getSetting('mail_host') !== null;
}

public function getOutgoingEmailConfig(): array
{
    return [
        'host' => $this->getSetting('mail_host'),
        'port' => $this->getSetting('mail_port', 587),
        'username' => $this->getSetting('mail_username'),
        'password' => $this->getSetting('mail_password'),
        'encryption' => $this->getSetting('mail_encryption', 'tls'),
        'from_address' => $this->getSetting('mail_from_address'),
        'from_name' => $this->getSetting('mail_from_name'),
    ];
}
```

Commands
--------

[](#commands)

### Send Pending Messages

[](#send-pending-messages)

Process pending message deliveries:

```
# Send all pending messages
php artisan emailer:send-pending

# Limit the number of messages processed
php artisan emailer:send-pending --limit=50

# Send for specific team only
php artisan emailer:send-pending --team=123

# Dry run (show what would be sent)
php artisan emailer:send-pending --dry-run
```

Email Tracking
--------------

[](#email-tracking)

The package includes comprehensive tracking features:

### Open Tracking

[](#open-tracking)

Automatically tracks when recipients open emails using invisible tracking pixels.

### Click Tracking

[](#click-tracking)

Tracks clicks on links within emails by automatically replacing URLs with tracked versions.

### Webhook Support

[](#webhook-support)

Receives real-time updates from email providers:

- **Mailgun**: `/emailer/webhook/mailgun`
- **SendGrid**: `/emailer/webhook/sendgrid`
- **MailBaby**: `/emailer/webhook/mailbaby`

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

[](#advanced-usage)

### Custom Email Providers

[](#custom-email-providers)

Extend the package to support additional email providers:

```
// In your SendMessageCampaignJob extension
protected function sendViaCustomProvider()
{
    // Implement your custom provider logic
}
```

### Template Variables

[](#template-variables)

The package supports template variables that are automatically replaced:

```
$message = Message::create([
    'content' => 'Hello {{name}}!Your email is {{email}}',
    // ...
]);
```

Available variables:

- `{{name}}` - Contact name
- `{{email}}` - Contact email
- Add custom variables by extending the `getHtmlForContact()` method

Model Relationships
-------------------

[](#model-relationships)

The package assumes certain relationships exist in your application:

```
// Your Team model should have:
public function messages()
{
    return $this->hasMany(\idoneo\Emailer\Models\Message::class);
}

// Your Contact model should have:
public function messageDeliveries()
{
    return $this->hasMany(\idoneo\Emailer\Models\MessageDelivery::class);
}

// Your Category model should have:
public function messages()
{
    return $this->hasMany(\idoneo\Emailer\Models\Message::class);
}
```

Performance
-----------

[](#performance)

### Queue Workers

[](#queue-workers)

Make sure you have queue workers running to process email jobs:

```
php artisan queue:work --queue=emailer
```

### Database Indexing

[](#database-indexing)

The package includes optimized database indexes for performance. For large volumes, consider:

- Partitioning delivery tables by date
- Archiving old delivery records
- Using read replicas for analytics queries

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [idoneo](https://github.com/idoneo)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

Test webhook functionality
==========================

[](#test-webhook-functionality)

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance78

Regular maintenance activity

Popularity0

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 59.4% 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 ~0 days

Total

10

Last Release

256d ago

Major Versions

v1.1.1 → v2.0.02025-08-28

### Community

Maintainers

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

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (376 commits)")[![mvdnbrk](https://avatars.githubusercontent.com/u/802681?v=4)](https://github.com/mvdnbrk "mvdnbrk (46 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (28 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (23 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (20 commits)")[![pforret](https://avatars.githubusercontent.com/u/474312?v=4)](https://github.com/pforret "pforret (16 commits)")[![diego-mascarenhas](https://avatars.githubusercontent.com/u/1038571?v=4)](https://github.com/diego-mascarenhas "diego-mascarenhas (15 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (14 commits)")[![riasvdv](https://avatars.githubusercontent.com/u/3626559?v=4)](https://github.com/riasvdv "riasvdv (10 commits)")[![patinthehat](https://avatars.githubusercontent.com/u/5508707?v=4)](https://github.com/patinthehat "patinthehat (10 commits)")[![crynobone](https://avatars.githubusercontent.com/u/172966?v=4)](https://github.com/crynobone "crynobone (8 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (8 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (7 commits)")[![thecaliskan](https://avatars.githubusercontent.com/u/13554944?v=4)](https://github.com/thecaliskan "thecaliskan (5 commits)")[![irfanm96](https://avatars.githubusercontent.com/u/42065936?v=4)](https://github.com/irfanm96 "irfanm96 (5 commits)")[![IGedeon](https://avatars.githubusercontent.com/u/694313?v=4)](https://github.com/IGedeon "IGedeon (4 commits)")[![abenerd](https://avatars.githubusercontent.com/u/7523903?v=4)](https://github.com/abenerd "abenerd (3 commits)")[![jessarcher](https://avatars.githubusercontent.com/u/4977161?v=4)](https://github.com/jessarcher "jessarcher (3 commits)")[![koossaayy](https://avatars.githubusercontent.com/u/6431084?v=4)](https://github.com/koossaayy "koossaayy (3 commits)")[![lloricode](https://avatars.githubusercontent.com/u/8251344?v=4)](https://github.com/lloricode "lloricode (3 commits)")

---

Tags

laravelsendgridmailgunemail marketingsmtpnewsletterEmail Trackingidoneoemaileremail-campaigns

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/diego-mascarenhas-emailer/health.svg)

```
[![Health](https://phpackages.com/badges/diego-mascarenhas-emailer/health.svg)](https://phpackages.com/packages/diego-mascarenhas-emailer)
```

###  Alternatives

[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[wnx/laravel-sends

Keep track of outgoing emails in your Laravel application.

200427.3k](/packages/wnx-laravel-sends)[spatie/laravel-discord-alerts

Send a message to Discord

151408.0k](/packages/spatie-laravel-discord-alerts)[spatie/laravel-mailcoach-sdk

An SDK to easily work with the Mailcoach API in Laravel apps

41290.2k1](/packages/spatie-laravel-mailcoach-sdk)[spatie/laravel-mailcoach-mailer

The driver for sending transactional mails using Mailcoach in Laravel

25325.1k](/packages/spatie-laravel-mailcoach-mailer)[creagia/laravel-web-mailer

Laravel Web Mailer

6923.5k](/packages/creagia-laravel-web-mailer)

PHPackages © 2026

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