Multi-provider email sending with automatic fallback (GSMTP, Brevo, GWORK, SES, Mailgun, Mailjet, MailerSend, Resend, SendGrid)
Project description
multi-email
Multi-provider email sending with automatic fallback.
Configure a priority-ordered list of email providers. The library tries each one in order — on any failure (auth error, rate limit, network issue) it automatically moves to the next. First success wins.
pip install multi-email
Supported providers
| Method | Free limit | Gmail sender | Notes |
|---|---|---|---|
| GSMTP | 500/day | ✅ Yes | Local dev only (cloud-blocked) |
| BREVO | 300/day | ✅ Yes* | Best free option |
| GWORK | ~2000/day | ✅ Yes | Paid ~Rs125/mo |
| SES | — | ✅ Yes* | $0.10/1000 — cheapest at scale |
| MAILGUN | 100/day | ❌ No | Needs own domain |
| MAILJET | 200/day | ✅ Yes* | EU/GDPR friendly |
| MAILERSEND | 3000/month | ❌ No | Best free volume |
| RESEND | 3000/month | ❌ No | Simple API |
| SENDGRID | 100/day | ❌ No | Industry standard |
* Verify your Gmail in their dashboard first.
Quick start
Option 1 — Environment variable
Set EMAIL_SEND_METHODS to a JSON array (ideal for Railway, Heroku, Docker, etc.):
export EMAIL_SEND_METHODS='[
{"method":"BREVO", "api_key":"xkeysib-AAA", "from_email":"you@gmail.com", "from_name":"MyApp"},
{"method":"BREVO", "api_key":"xkeysib-BBB", "from_email":"you@gmail.com", "from_name":"MyApp"},
{"method":"MAILJET", "api_key":"abc123", "api_secret":"xyz789", "from_email":"you@gmail.com", "from_name":"MyApp"},
{"method":"SES", "user":"AKIAXXXXXXXX", "password":"xxxx", "from_email":"you@gmail.com", "from_name":"MyApp", "region":"ap-south-1"},
{"method":"RESEND", "api_key":"re_xxx", "from_email":"noreply@yourdomain.com","from_name":"MyApp"},
{"method":"SENDGRID", "api_key":"SG.xxx", "from_email":"noreply@yourdomain.com","from_name":"MyApp"}
]'
from multi_email import send_email
ok = send_email("user@example.com", "Welcome!", "<h1>Hello!</h1>")
Option 2 — Pass methods directly
from multi_email import send_email
methods = [
{"method": "BREVO", "api_key": "xkeysib-AAA", "from_email": "you@gmail.com", "from_name": "MyApp"},
{"method": "RESEND", "api_key": "re_xxx", "from_email": "noreply@yourdomain.com", "from_name": "MyApp"},
]
ok = send_email("user@example.com", "Welcome!", "<h1>Hello!</h1>", methods=methods)
Test mode (no real sends)
send_email("user@example.com", "Test", "<p>hi</p>", test_mode=True)
API
send_email(to, subject, html_body, *, methods=None, test_mode=False) -> bool
| Parameter | Type | Description |
|---|---|---|
to |
str |
Recipient email address |
subject |
str |
Email subject line |
html_body |
str |
Full HTML body |
methods |
list | None |
Override the env-var provider list for this call |
test_mode |
bool |
If True, log the email and return True without sending |
Returns True on first successful send, False only if every provider fails.
load_methods(env_var="EMAIL_SEND_METHODS") -> list
Re-read and parse the method list from an environment variable. Useful if you update the env var at runtime.
Provider setup
BREVO (best free option — 300/day, Gmail sender)
- Sign up at brevo.com
- Senders & IPs → Add sender → verify your Gmail address
- API Keys → Generate a new API key
{"method":"BREVO", "api_key":"xkeysib-...", "from_email":"you@gmail.com", "from_name":"MyApp"}
Add multiple BREVO entries with different accounts to stack free limits.
GSMTP (Gmail personal SMTP — local dev only)
- Google Account → Security → 2-Step Verification → App Passwords → create one
- Use it as the
password(not your real Gmail password)
{"method":"GSMTP", "user":"you@gmail.com", "password":"xxxx xxxx xxxx xxxx", "from_email":"you@gmail.com", "from_name":"MyApp"}
⚠️ Blocked on Railway, Heroku, and most cloud hosts.
GWORK (Google Workspace — ~2000/day)
- workspace.google.com → buy plan → create a user
- Use that user's email + password
{"method":"GWORK", "user":"support@yourdomain.com", "password":"xxxxx", "from_email":"support@yourdomain.com", "from_name":"MyApp"}
SES (Amazon SES — cheapest at scale)
- AWS Console → SES → Verified Identities → verify your sender email
- Request Production Access (sandbox → production, ~24 hr approval)
- SES → SMTP Settings → Create SMTP Credentials → copy user + password
{"method":"SES", "user":"AKIAXXXXXXXXXXXXXXXX", "password":"xxxx", "from_email":"support@yourdomain.com", "from_name":"MyApp", "region":"ap-south-1"}
Regions: ap-south-1 (Mumbai), us-east-1, ap-southeast-1
MAILGUN (100/day free)
- mailgun.com → Sending → Domains → Add domain → configure DNS
- API Keys → create private key
{"method":"MAILGUN", "api_key":"key-xxx", "domain":"mg.yourdomain.com", "from_email":"noreply@yourdomain.com", "from_name":"MyApp"}
EU accounts: add "base_url": "https://api.eu.mailgun.net"
MAILJET (200/day free, EU-friendly)
- mailjet.com → free account
- Senders & Domains → Add sender → verify your Gmail
- API Keys → copy both API Key and Secret Key
{"method":"MAILJET", "api_key":"abc123", "api_secret":"xyz789", "from_email":"you@gmail.com", "from_name":"MyApp"}
MAILERSEND (3000/month free)
- mailersend.com → free account
- Domains → Add domain → verify DNS
- API Tokens → Generate token
{"method":"MAILERSEND", "api_key":"mlsn.xxx", "from_email":"noreply@yourdomain.com", "from_name":"MyApp"}
RESEND (3000/month free)
- resend.com → add domain → verify DNS
- API Keys → create key
{"method":"RESEND", "api_key":"re_xxx", "from_email":"noreply@yourdomain.com", "from_name":"MyApp"}
SENDGRID (100/day free)
- sendgrid.com → Settings → Sender Authentication → verify domain
- API Keys → create key with Mail Send permission
{"method":"SENDGRID", "api_key":"SG.xxx", "from_email":"noreply@yourdomain.com", "from_name":"MyApp"}
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file multi_email-1.0.0.tar.gz.
File metadata
- Download URL: multi_email-1.0.0.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3d51e3dcd56ede8bdffe3428922ea63ebce4a1c9b62f229fe7743415318796f
|
|
| MD5 |
b0702e6b92003fc1e6e8d2fb1d616deb
|
|
| BLAKE2b-256 |
0243b715eb71d38a680b7805b69b693374417f4db681ca2f8779116989b98d39
|
File details
Details for the file multi_email-1.0.0-py3-none-any.whl.
File metadata
- Download URL: multi_email-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67868c0253db9ae7223ecb353f526fb83c9451e255287bf571e579d77172e995
|
|
| MD5 |
a94d84ba3ac3edf16857d61c8cd13737
|
|
| BLAKE2b-256 |
a0c2202e573b99cdbb9c2a5cf1765b61e79721d3e30b7b922e7c3f94e34ba6c7
|