Skip to content

Python

There’s no official 3AVA Mail Python client — but the API is wire-compatible with Resend’s, so the official resend PyPI package works out of the box. Or use requests / httpx directly.

Terminal window
pip install resend
import resend
resend.api_key = "am_YOUR_KEY"
resend.api_url = "https://mail.3ava.com/api"
resend.Emails.send({
"from": "Acme <[email protected]>",
"to": ["[email protected]"],
"subject": "Hello",
"html": "<p>Hi.</p>",
})
import requests
API_KEY = "am_YOUR_KEY"
BASE = "https://mail.3ava.com/api"
def send_email(**fields):
r = requests.post(
f"{BASE}/emails",
headers={"Authorization": f"Bearer {API_KEY}"},
json=fields,
timeout=30,
)
r.raise_for_status()
return r.json()
result = send_email(
**{"from": "Acme <[email protected]>"},
subject="Hello",
html="<p>Hi.</p>",
)
print(result["id"])
import httpx
async def send_email(**fields):
async with httpx.AsyncClient(timeout=30) as client:
r = await client.post(
"https://mail.3ava.com/api/emails",
headers={"Authorization": "Bearer am_YOUR_KEY"},
json=fields,
)
r.raise_for_status()
return r.json()
import uuid
requests.post(
f"{BASE}/emails",
headers={
"Authorization": f"Bearer {API_KEY}",
"Idempotency-Key": f"order-{order_id}-receipt",
},
json={...},
)
import base64
with open("invoice.pdf", "rb") as f:
encoded = base64.b64encode(f.read()).decode()
send_email(
**{"from": "Acme <[email protected]>"},
subject="Invoice",
html="<p>Attached.</p>",
attachments=[{
"filename": "invoice.pdf",
"content": encoded,
"content_type": "application/pdf",
}],
)