Install
pip install maildeno
# or
poetry add maildeno
# or
uv add maildeno
Requires Python 3.9+ and httpx >= 0.28.1, < 1.0 (installed automatically).
Configure the client
Configuration options
| Option | Type | Default | Description |
|---|---|---|---|
|
|
— |
Required. Your Maildeno API key. |
|
|
|
Request timeout in seconds. Raises |
|
|
— |
Bring your own |
Client lifecycle
For long-lived applications (web servers, workers), instantiate once at startup and reuse:
# module-level — reused across all requests
maildeno = MaildenoClient(api_key=os.environ["MAILDENO_API_KEY"])
For short-lived scripts, use the context manager so the underlying connection is closed cleanly:
with MaildenoClient(api_key=os.environ["MAILDENO_API_KEY"]) as client:
html = client.render_html("template-id")
# httpx transport is closed here
async with AsyncMaildenoClient(api_key=os.environ["MAILDENO_API_KEY"]) as client:
html = await client.render_html("template-id")
Bring your own httpx client
For advanced use cases — custom proxies, mTLS, retries, observability hooks — inject a pre-configured httpx client:
import httpx
from maildeno import MaildenoClient
http = httpx.Client(
timeout=15.0,
transport=httpx.HTTPTransport(retries=3),
headers={"X-Tenant-Id": "acme-corp"},
)
client = MaildenoClient(api_key=os.environ["MAILDENO_API_KEY"], http_client=http)
# You own the lifecycle when you inject a client — close it yourself
# ...
http.close()
| When you inject an HTTP client, the SDK will not close it. You are responsible for its lifecycle. |