Overview

FastAPI-Mail 1.4, released on November 23, 2024, adds Pydantic v2 support.

Main Features

Pydantic v2

Configuration and message schemas now use Pydantic v2, with better validation performance and the new model syntax.

python
from fastapi_mail import ConnectionConfig

# Pydantic v2: faster validation
conf = ConnectionConfig(
    MAIL_USERNAME='user@example.com',
    MAIL_PASSWORD='password',
    MAIL_FROM='user@example.com',
    MAIL_SERVER='smtp.example.com',
    MAIL_PORT=587,
    MAIL_STARTTLS=True,
    MAIL_SSL_TLS=False,
)
print(conf.model_dump())  # Pydantic v2 API

Sources