Send email from FastAPI over SMTP
Call Python's SMTP client from a FastAPI route. Same host, username, and API-key password as every other stack.
Send from a route
Pythonimport os import smtplib from email.message import EmailMessage from fastapi import FastAPI app = FastAPI() @app.post("/send") def send() -> dict[str, bool]: msg = EmailMessage() msg["From"] = "you@yourdomain.com" msg["To"] = "customer@example.com" msg["Subject"] = "Hello from FastAPI" msg.set_content("Sent via SMTP.") with smtplib.SMTP("smtp.unitpost.com", 587) as smtp: smtp.starttls() smtp.login("unitpost", os.environ["UNITPOST_API_KEY"]) smtp.send_message(msg) return {"ok": True}Verify delivery
Confirm in Activity.