Documentation
Send email in Python.
Works with: Python 3.9 or newer. No dependencies.
Install
Get a key under API keys in the dashboard and verify a sending domain first (how). Then add the library:
Send an email
This sends one message and passes an idempotency key, so repeating the request can never deliver it twice. A send is retried only when you pass an idempotency_key; reads and deletes retry on 429 and 5xx. from_ is sent as from.
More on what you can put in a message (cc, bcc, attachments, tags, templates, scheduling) is under Sending.
Verify webhook signatures
Mailtruss signs every webhook with the Standard Webhooks scheme. Check the signature before you trust a request. Pass the raw body exactly as received, the request headers and the endpoint's signing secret. It raises ValueError when a header is missing, the timestamp is more than five minutes off, or no signature matches.
Events, payloads and retries are on the Webhooks page.
Handle errors
Any non-2xx response raises MailtrussError with status, name, message and request_id; a timeout raises MailtrussTimeout. Every error name, with its cause and fix, is in the error catalogue.