Skip to main content

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)
  1. Sign up at brevo.com
  2. Senders & IPs → Add sender → verify your Gmail address
  3. 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)
  1. Google Account → Security → 2-Step Verification → App Passwords → create one
  2. 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)
  1. workspace.google.com → buy plan → create a user
  2. 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)
  1. AWS Console → SES → Verified Identities → verify your sender email
  2. Request Production Access (sandbox → production, ~24 hr approval)
  3. 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)
  1. mailgun.com → Sending → Domains → Add domain → configure DNS
  2. 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)
  1. mailjet.com → free account
  2. Senders & Domains → Add sender → verify your Gmail
  3. 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)
  1. mailersend.com → free account
  2. Domains → Add domain → verify DNS
  3. API Tokens → Generate token
{"method":"MAILERSEND", "api_key":"mlsn.xxx", "from_email":"noreply@yourdomain.com", "from_name":"MyApp"}
RESEND (3000/month free)
  1. resend.com → add domain → verify DNS
  2. API Keys → create key
{"method":"RESEND", "api_key":"re_xxx", "from_email":"noreply@yourdomain.com", "from_name":"MyApp"}
SENDGRID (100/day free)
  1. sendgrid.com → Settings → Sender Authentication → verify domain
  2. API Keys → create key with Mail Send permission
{"method":"SENDGRID", "api_key":"SG.xxx", "from_email":"noreply@yourdomain.com", "from_name":"MyApp"}

License

MIT

Metadata

Release files for multi-email 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for multi-email 1.0.0
File Size Uploaded Provenance Actions
multi_email-1.0.0.tar.gz 9.6 kB Without provenance Details for multi_email-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for multi-email 1.0.0
File Interpreter ABI Platform Actions
multi_email-1.0.0-py3-none-any.whl Python 3 none any Details for multi_email-1.0.0-py3-none-any.whl

Total release size: 18.4 kB

Release files / multi_email-1.0.0.tar.gz

Download URL multi_email-1.0.0.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b3d51e3dcd56ede8bdffe3428922ea63ebce4a1c9b62f229fe7743415318796f
BLAKE2b-256 checksum
How to use checksums
0243b715eb71d38a680b7805b69b693374417f4db681ca2f8779116989b98d39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.6

Release files / multi_email-1.0.0-py3-none-any.whl

Download URL multi_email-1.0.0-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
67868c0253db9ae7223ecb353f526fb83c9451e255287bf571e579d77172e995
BLAKE2b-256 checksum
How to use checksums
a0c2202e573b99cdbb9c2a5cf1765b61e79721d3e30b7b922e7c3f94e34ba6c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.6

Security for multi-email 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page