Skip to main content

Instantiation

See Authentication for both approaches.

Composing a message

Use the Mail helper to compose messages. It handles formatting and automatically base64-encodes HTML content before sending.
Call mail.get() to get the formatted dict ready for the API.

Attachments

Pass attachments via the optional_headers dict:

Send a message

Check delivery status

Common deliveryStatus values: delivered, opened, failed, pending.

The Response object

Both send and get return a Response object:

Error handling

Both methods raise requests.exceptions.HTTPError on non-2xx responses. Wrap calls in a try/except block:
The optional handle_error helper prints the error response body before re-raising: