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.
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.
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='...')
# This call is always the same — regardless of provider
response = mailer.send(
to='user@example.com',
subject='Welcome!',
body='Hello!
Great to have you.
'
)
print(f"Sent! Message ID: {response.message_id}")
Features
Same send() and send_bulk() API across all six providers.
Send provider-hosted templates with dynamic data on all providers.
Attach any file using pathlib.Path — works on all providers.
Send thousands of emails using each provider's native batch API.
156 unit tests, 96% coverage, battle-tested in production.
SMTP and Postmark work out of the box. Other providers install only what you need.
Providers
MailBridge supports six providers. All share the same interface — only the initialization differs:
| Provider | Templates | Bulk API | Tracking | Extra install |
|---|---|---|---|---|
| SendGrid | ✓ | ✓ Native | ✓ | mailbridge[sendgrid] |
| Amazon SES | ✓ | ✓ Native | ✓ | mailbridge[ses] |
| Postmark | ✓ | ✓ Native | ✓ | — |
| Mailgun | ✓ | ✓ Native | ✓ | — |
| Brevo | ✓ | ✓ Native | ✓ | — |
| SMTP | — | — | — | — |
Not sure which to choose? SMTP works with any email account and requires no sign-up — great for getting started. For production, SendGrid and Postmark are the most popular choices for transactional email.
Use Cases
MailBridge covers the most common transactional email patterns:
Send welcome emails with activation links and onboarding instructions using provider templates.
Trigger time-sensitive reset emails with secure links and expiry information.
Send order receipts with itemized content, tracking numbers, and dynamic pricing.
Send thousands of personalized emails efficiently using send_bulk() with each provider's native batch API.
Send system notifications, payment alerts, or status updates to users and admins.
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.
The design goal is zero lock-in. If you decide to switch from SendGrid to Amazon SES six months from now because of pricing, deliverability, or features — you update one line of configuration. Your send logic, template calls, bulk sending, and error handling all stay exactly as they are.