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+ 156 tests 96% coverage
$ pip install 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='...')

# 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

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.

Production Ready

156 unit tests, 96% coverage, battle-tested in production.

Minimal dependencies

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:

ProviderTemplatesBulk APITrackingExtra 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:

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 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.