Looking to hire Laravel developers? Try LaraJobs

laravel-mailbridge maintained by ashraful19

Description
Provider-neutral transactional and marketing email bridge for Laravel.
Last update
2026/05/05 11:51 (dev-dev)
License
Links
Downloads
0

Comments
comments powered by Disqus

Laravel MailBridge

Tests Docs Latest Version PHP Version Laravel Version License: MIT

Provider-neutral transactional and marketing email for Laravel 12+.

MailBridge keeps your application code stable while providers, SDKs, template ids, and marketing APIs vary behind adapters. Use normal Laravel mail when you want it. Use MailBridge when you need provider-hosted templates, marketing lists, capability checks, tested SDK pins, and provider fallback.

Documentation

Full docs: https://ashraful19.github.io/laravel-mailbridge/

Source docs:

Quick Start

composer require ashraful19/laravel-mailbridge
php artisan vendor:publish --tag=mailbridge-config
php artisan mailbridge:install

mailbridge:install opens a terminal checklist so you can install one or more provider SDKs. The base package does not install every SDK.

Basic Usage

Existing Laravel mail stays unchanged:

Mail::to($user)->send(new WelcomeMail($user));

Send a Laravel Mailable through MailBridge:

MailBridge::transactional()
    ->to($user->email, $user->name)
    ->send(new WelcomeMail($user));

Send a provider-hosted template:

MailBridge::transactional()
    ->template('welcome')
    ->to($user->email)
    ->data(['name' => $user->name])
    ->send();

Send through one provider for this request:

MailBridge::transactional('postmark')
    ->withFallback(false)
    ->to($user->email)
    ->subject('Welcome')
    ->text('Hello')
    ->send();

Subscribe a marketing contact:

use Ashraful19\LaravelMailbridge\Data\Subscriber;

MailBridge::marketing()
    ->list('signup')
    ->subscribe(Subscriber::make($user->email)->name($user->name));

Providers

Provider SDKs are installed only when selected, and each install command uses the exact SDK version tested by MailBridge.

Provider Lane Install
Brevo Transactional + marketing php artisan mailbridge:install brevo
MailerSend Transactional php artisan mailbridge:install mailersend
Resend Transactional php artisan mailbridge:install resend
Postmark Transactional php artisan mailbridge:install postmark
Mailgun Transactional php artisan mailbridge:install mailgun
MailerLite Marketing php artisan mailbridge:install mailerlite

Run health checks anytime:

php artisan mailbridge:doctor

Features

Transactional email:

Feature Purpose
Raw HTML/text send Send simple app-rendered messages without a Laravel Mailable.
Laravel Mailable send Keep existing Laravel mail classes and route them through MailBridge.
Provider-hosted templates Send by config alias with template('welcome') or direct id with templateId(...).
Recipients Normalize to, cc, bcc, from, and replyTo across providers.
Attachments Support provider attachment APIs where available.
Tags/categories Attach provider analytics tags where supported.
Metadata/custom args Attach safe message metadata for provider analytics and webhook correlation.
Provider override Send one message through a specific provider without changing config.
Fallback control Use withFallback() or withFallback(false) per send.
Testing fake Assert transactional sends without touching provider APIs.

Marketing email:

Feature Purpose
Subscriber upsert Create or update marketing contacts.
Subscriber lookup/delete Manage contacts where provider supports it.
List/group subscribe Subscribe contacts to configured list aliases.
Unsubscribe Remove contacts from lists or marketing audiences.
Fields/attributes Sync custom subscriber profile data.
Tags/groups Attach provider grouping/tag concepts where supported.
Campaign operations Create, update, send, schedule, and read reports where supported.
Provider override Run one marketing operation through a specific provider.
Fallback control Retry transient provider/network failures through configured fallbacks.
Testing fake Assert marketing subscriptions without provider calls.

Why MailBridge

Need MailBridge behavior
Keep Laravel Mailable classes Mail::send() still works; MailBridge can also send Mailable objects.
Avoid installing every SDK Provider SDKs are optional and installed per provider.
Prevent surprise SDK breaks Install commands use tested exact versions.
Use hosted templates Send by template('welcome') alias or direct templateId('...').
Switch provider per send Pass provider name: MailBridge::transactional('postmark').
Control fallback Use withFallback() or withFallback(false) per send.
Test safely Use MailBridge::fake() and assertions.

License

Laravel MailBridge is open-sourced software licensed under the MIT license.