--- id: fastapi-mail version: "1.6.5" license: MIT license_treatment: permissive maintenance: active --- # fastapi-mail — Simple lightweight mail library for FastApi License: permissive · Maintenance: active · Downloads: 1.4M/mo ## 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 ". 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 above — 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 pip install fastapi-mail uv add fastapi-mail 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_current - Install friction: low - Maintenance: active - Downloads: 1.4M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags fastapi email sending, async smtp mail library, bulk email with fastapi, html email templates, fastapi background email tasks, async-email, smtp-client [View on SkillFed](https://skillfed.io/packages/fastapi-mail) · [View on PyPI](https://pypi.org/project/fastapi-mail/)