skillfed

fastapi-mail

Simple lightweight mail library for FastApi

fastapi-mail v1.6.5 1.4M downloads/30d#3,914 on PyPI
Permissive license MIT Active released

What it is and what it does

fastapi-mail is a lightweight async email library designed for FastAPI applications. It wraps aiosmtplib to send emails and attachments over SMTP, supporting both individual and bulk sends. The package integrates with FastAPI's background task system, allowing you to queue email sends without blocking request handling. It includes utilities for validating email addresses and supports Jinja2 HTML templates for message bodies, plus a NameEmail format that lets recipients be specified as "Name <email@domain.com>".

The library is built on standard async patterns (aiosmtplib, httpx, pydantic) and requires Python 3.10+. Configuration is handled via a ConnectionConfig object where you supply SMTP credentials, server details, and TLS settings. You create a FastMail instance, build a MessageSchema with subject, recipients, and body, then call send_message() to dispatch it asynchronously.

Use it for:

  • Send transactional emails (password resets, confirmations) from FastAPI endpoints without blocking the response.
  • Queue bulk email campaigns using FastAPI background tasks to distribute sends over time.
  • Render personalized HTML emails using Jinja2 templates with dynamic data from your application.
  • Validate recipient email addresses before sending using the built-in email utility classes.
  • Attach files from server storage or form uploads to outgoing messages.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Sends emails and attachments asynchronously from FastAPI applications using SMTP, with support for HTML templates, bulk messaging, and background task integration.

Yes. fastapi-mail is actively maintained, has low install friction, carries no known vulnerabilities, and is the standard choice for async email in FastAPI projects. The MIT license imposes no restrictions. Install it if you need to send email from a FastAPI application.

Install

fastapi-mail on PyPI

pip

pip install fastapi-mail

uv

uv add fastapi-mail

poetry

poetry add fastapi-mail

Installing fastapi-mail

Before you install

Low friction install with a pure-Python wheel. Active maintenance with a release within the last 57 days. Depends on 11 runtime packages including cryptography and email-validator, all standard ecosystem choices.

License in practice

MIT license is permissive; you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.

Quickstart

pip install fastapi-mail

from fastapi_mail import ConnectionConfig, FastMail, MessageSchema
from fastapi import FastAPI

conf = ConnectionConfig(
    MAIL_USERNAME="user",
    MAIL_PASSWORD="pass",
    MAIL_FROM="sender@example.com",
    MAIL_PORT=465,
    MAIL_SERVER="smtp.example.com",
    MAIL_SSL_TLS=True
)

app = FastAPI()
fm = FastMail(conf)
await fm.send_message(MessageSchema(subject="Test", recipients=["user@example.com"], body="Hello"))

Requires Python 3.10 or later. SMTP server credentials and network access to a mail server are required at runtime.

Verify before relying

  • Whether the package handles connection pooling or reuses SMTP connections efficiently under load.
  • Performance characteristics when sending bulk emails (number of concurrent sends, rate limits).
  • Whether Jinja2 template rendering is automatic or requires manual setup beyond what the fact sheet shows.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 11 — aiosmtplib, blinker, cryptography, email-validator, httpx, jinja2, pydantic, pydantic-settings, regex, starlette, typing-extensions
Maintenance actively maintained — 57 days since the last release
First released
Downloads 1,426,701/month — #3,914 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: fastapi_mail-1.6.5-py3-none-any.whl

License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14

Tags

fastapi email sendingasync smtp mail librarybulk email with fastapihtml email templatesfastapi background email tasks
async-emailsmtp-client

More Dynamic Content packages