Instantiation
Composing a message
Use theMail helper to compose messages. It handles formatting and automatically base64-encodes HTML content before sending.
mail.get() to get the formatted dict ready for the API.
Attachments
optional_headers dict:
Send a message
Check delivery status
deliveryStatus values: delivered, opened, failed, pending.
The Response object
Bothsend and get return a Response object:
Error handling
Both methods raiserequests.exceptions.HTTPError on non-2xx responses. Wrap calls in a try/except block:
handle_error helper prints the error response body before re-raising: