Fastapi-mail
Simple lightweight mail system for FastAPI — send emails, attachments, and HTML templates.
Documentation: sabuhish.github.io/fastapi-mail
Installation
pip install fastapi-mail
Quick Start
from typing import List
from fastapi import FastAPI
from fastapi_mail import ConnectionConfig, FastMail, MessageSchema, MessageType, NameEmail
from pydantic import BaseModel
from starlette.responses import JSONResponse
class EmailSchema(BaseModel):
email: List[NameEmail]
conf = ConnectionConfig(
MAIL_USERNAME="username",
MAIL_PASSWORD="**********",
MAIL_FROM="test@email.com",
MAIL_PORT=465,
MAIL_SERVER="mail server",
MAIL_STARTTLS=False,
MAIL_SSL_TLS=True,
USE_CREDENTIALS=True,
VALIDATE_CERTS=True,
)
app = FastAPI()
@app.post("/email")
async def simple_send(email: EmailSchema) -> JSONResponse:
message = MessageSchema(
subject="Fastapi-Mail module",
recipients=email.model_dump().get("email"),
body="<p>Thanks for using Fastapi-mail</p>",
subtype=MessageType.html,
)
await FastMail(conf).send_message(message)
return JSONResponse(status_code=200, content={"message": "email has been sent"})
Contributing
Contributions of any kind are welcome! Please read CONTRIBUTING before you start.
Contributors
Thanks goes to these wonderful people.
LICENSE
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fastapi_mail-1.6.7.tar.gz
(13.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastapi_mail-1.6.7.tar.gz.
File metadata
- Download URL: fastapi_mail-1.6.7.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
poetry/2.4.1 CPython/3.11.16 Linux/6.17.0-1022-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca672e4778158513484c76ed380ea6000a293abfbc944a3a6c0ecd6e679c70bc
|
|
| MD5 |
2b915c2123284de6bf346418b2fbd349
|
|
| BLAKE2b-256 |
99102084bb7bb1a63964b496438ba6f456600a186fc7e2e7b876bfef21aaa126
|
File details
Details for the file fastapi_mail-1.6.7-py3-none-any.whl.
File metadata
- Download URL: fastapi_mail-1.6.7-py3-none-any.whl
- Upload date:
- Size: 15.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
poetry/2.4.1 CPython/3.11.16 Linux/6.17.0-1022-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1ebdf1592a2e26e2409f5f812319e2aecf9a9da54fd37540b179b03e3866072
|
|
| MD5 |
64cd048472c3367b523aae57ff699038
|
|
| BLAKE2b-256 |
f48b3cea48ceb7d56766b0505c23bf11677a2fafc934a028dcbd19df7dda0bb8
|