Quickstarts
Send with Python
Send your first email from Python with the usend SDK.
You need a verified domain and an API key. The SDK has no dependencies.
1. Install
pip install usend2. Set your API key
export USEND_API_KEY="us_123456789"3. Send
from usend import Usend, UsendError
usend = Usend() # reads USEND_API_KEY; or Usend("us_...")
try:
email = usend.emails.send({
"from": "Acme <[email protected]>",
"to": ["[email protected]"],
"subject": "Hello from usend",
"html": "<p>It works!</p>",
})
print("queued", email["id"])
except UsendError as e:
print("failed:", e)python send.pyMethods return the API's JSON as dicts and raise UsendError on failure.
Idempotent sends
usend.emails.send(payload, idempotency_key="welcome-user-123")A retry with the same key returns the first result instead of sending again. See Idempotency.
Attachments
import base64
with open("invoice.pdf", "rb") as f:
content = base64.b64encode(f.read()).decode()
usend.emails.send({
"from": "Acme <[email protected]>",
"to": ["[email protected]"],
"subject": "Your invoice",
"text": "Attached.",
"attachments": [{"filename": "invoice.pdf", "content": content}],
})SMTP settings
usend.smtp_settings() returns the host, port, username and password for any SMTP library. See Send with SMTP.
Next steps
Framework guides: Flask, FastAPI, Django. Then Send emails.