Quick setup examples
Python
Send your first email from Python using requests against the SendDart API.
SendDart ships an official Python SDK — see Send emails with Python for the pip install senddart path — but you do not need it: this guide sends email by POSTing JSON to https://www.senddart.com/api/emails. The examples below use the popular `requests` library, but any HTTP client (including the stdlib urllib) works.
Prerequisites
- A SendDart API key.
- A verified domain to send from.
- Python 3.8 or newer if you install the official
senddartpackage (it declaresrequires-python >= 3.8). Therequestsexample below runs on older interpreters too.
1. Install an HTTP client
Pip
pip install requests2. Set your API key
Read your key from the environment so it never lives in source.
.env
SENDDART_API_KEY=mb_xxxxxxxxx3. Send email using HTML
The easiest way to send an email is with the html field.
import os
import requests
res = requests.post(
"https://www.senddart.com/api/emails",
headers={"Authorization": f"Bearer {os.environ['SENDDART_API_KEY']}"},
json={
"from": "Acme <onboarding@yourdomain.com>",
"to": ["delivered@test.senddart.com"],
"subject": "hello world",
"html": "<strong>it works!</strong>",
},
)
res.raise_for_status()
print(res.json()["id"])Inside Flask, FastAPI, or Django, call the API the same way from your view/route handler. See Send an email for every body field.