Docs / mailbridge / Overview

MailBridge

A unified Python email library with multi-provider support. Write your email logic once — switch between SendGrid, Amazon SES, Postmark, Mailgun, Brevo, or plain SMTP by changing a single line.

Open Source MIT License Python 3.10+ 220+ tests 92% coverage
$ uv add mailbridge

Introduction

Every production application sends emails — welcome messages, password resets, order confirmations, newsletters. The challenge is that each email provider has its own SDK, its own API design, and its own quirks. Switching providers means rewriting email code throughout your codebase.

MailBridge solves this with a single, consistent interface. You configure a provider once, and every mailer.send() call works identically regardless of which provider is behind it. Switching from SendGrid to Amazon SES is a one-line change in your configuration — no other code changes needed.

Same code — different provider:
python
from mailbridge import MailBridge

# Change provider here — nothing else changes
mailer = MailBridge(provider='sendgrid', api_key='SG.xxxxx', from_email='hi@example.com')
# mailer = MailBridge(provider='ses',       aws_access_key_id='AKIA...', region_name='us-east-1', from_email='hi@example.com')
# mailer = MailBridge(provider='postmark',  server_token='xxxxx',         from_email='hi@example.com')
# mailer = MailBridge(provider='smtp',      host='smtp.gmail.com', port=587, username='...', password='...')

response = mailer.send(
    to='user@example.com',
    subject='Welcome!',
    body='

Hello!

Great to have you.

' ) print(f"Sent! Message ID: {response.message_id}")

Features

Unified Interface

Same send() and send_bulk() API across all six providers.

Template Support

Send provider-hosted templates with dynamic data on all providers.

Attachment Support

Attach any file using pathlib.Path — works on all providers.

Bulk Sending

Send thousands of emails using each provider's native batch API.

Async Support

AsyncMailBridge for FastAPI and asyncio apps — native aiohttp and aiosmtplib.

Minimal dependencies

SMTP and Postmark work out of the box. Install only what you need.

Providers

MailBridge supports six providers. All share the same interface — only the initialization differs:

ProviderTemplatesBulk APIAsync I/OExtra install
SendGrid✓ Native✓ aiohttpmailbridge[sendgrid]
Amazon SES✓ Native✓ thread poolmailbridge[ses]
Postmark✓ Native✓ aiohttp
Mailgun✓ Native✓ aiohttp
Brevo✓ Native✓ aiohttp
SMTP✓ aiosmtplib

Use Cases

Welcome & Onboarding

Send welcome emails with activation links and onboarding instructions using provider templates.

Password Reset

Trigger time-sensitive reset emails with secure links and expiry information.

Order Confirmations

Send order receipts with itemized content, tracking numbers, and dynamic pricing.

Newsletters & Campaigns

Send thousands of personalized emails efficiently using send_bulk() with each provider's native batch API.

Notifications & Alerts

Send system notifications, payment alerts, or status updates to users and admins.

Invoices & Reports

Attach PDFs directly from pathlib.Path — invoices, reports, contracts — on any provider.

How it works

MailBridge is a thin abstraction layer. When you call mailer.send(), it translates your unified message into whatever format the selected provider's API expects — then returns a normalized EmailResponse object regardless of what came back.

Your code
mailer.send(...)
MailBridge
Unified interface
Email Provider
SendGrid / SES / ...
Response
EmailResponse

The design goal is zero lock-in. If you decide to switch from SendGrid to Amazon SES six months from now — you update one line of configuration. Your send logic, template calls, bulk sending, and error handling all stay exactly as they are.