Send with Python

requests and a dict are the whole integration.

Prefer a typed client (sync or async)? The official Python SDK (pip install camelmailer) is client.emails.send({ … }) with typed exceptions. The plain requests recipe below keeps the dependency you already have.

The basic send

mailer.py
import os, requests

def send_mail(**message):
    r = requests.post(
        f"{os.environ['CAMELMAILER_URL']}/api/v2/server/messages",
        headers={"X-Server-API-Key": os.environ["CAMELMAILER_KEY"]},
        json=message,
    )
    body = r.json()
    if body["status"] != "success":
        raise RuntimeError(body["error"])
    return body["data"]
usage
send_mail(
    from="billing@yourdomain.com",  # or: **{"from": …} to dodge the keyword
    to=[user.email],
    subject="Your receipt",
    text_body=f"Thanks! You paid €{amount}.",
)

from is a Python keyword, so pass the payload as a dict (send_mail(**payload)) or build the dict inline.

Attachments

import base64

payload["attachments"] = [{
    "name": "invoice.pdf",
    "content_type": "application/pdf",
    "data_base64": base64.b64encode(pdf_bytes).decode(),
}]

Django / Flask

Either call the API as above from your task queue, or configure the framework's SMTP backend against your instance via SMTP settings. The API gives you per-recipient ids and stable error codes; SMTP means zero new code.

Full field reference: Messages API. Templates work the same way via /messages/with_template.