Envello
Tutorial

Sending transactional email from FastAPI

Envello Team·2026-07-17·5 min read

FastAPI's whole design leans on async, so the natural fit is an async HTTP client (httpx, which most FastAPI projects already pull in) rather than a blocking call inside an async request handler.

The async call

  • import httpx
  • async with httpx.AsyncClient() as client: response = await client.post('https://api.envello.dev/emails', headers={'Authorization': f'Bearer {settings.envello_api_key}'}, json={'from': 'Acme <[email protected]>', 'to': user.email, 'subject': 'Welcome!', 'html': rendered_html})
  • response.raise_for_status() to surface a failed send as an exception rather than a silently ignored error

Don't block the response on the send

For anything triggered by an incoming request (signup, password reset), use FastAPI's BackgroundTasks so the send happens after the response is already returned to the client, rather than making the user wait on Envello's API round-trip before they get a response from your endpoint:

If you want an SDK instead of httpx directly

A Python SDK exists (packages/sdk-python, pip install envello), honest caveat: not yet published to PyPI, install from the local path or git source for now. For a FastAPI project already comfortable with httpx and Pydantic for request validation, the direct approach above is often simpler than adding another client library for a handful of send calls.

Envello

EU-hosted transactional email, done right by default.