Send emails with FastAPI
Prerequisites
Section titled “Prerequisites”Before you start, you'll need:
- A Resend API key
- A verified domain
Install
Get the Resend Python SDK.
Pip pip install resendSend email using HTML
The easiest way to send an email is by using the
htmlparameter.main.py import os from typing import Dict from fastapi import FastAPI import resend resend.api_key = os.environ["RESEND_API_KEY"] app = FastAPI() @app.post("/") def send_mail() -> Dict: params: resend.Emails.SendParams = { "from": "Acme <onboarding@resend.dev>", "to": ["delivered@resend.dev"], "subject": "hello world", "html": "<strong>it works!</strong>", } email: resend.Emails.SendResponse = resend.Emails.send(params) return email
Examples
Section titled “Examples”FastAPI App
Full FastAPI web application
Basic Send
Basic email sending
Attachments
Send emails with file attachments
Templates
Send emails using Resend hosted templates
Scheduling
Schedule emails for future delivery
Audiences
Manage contacts and audiences
Domains
Create and manage sending domains
Inbound Webhooks
Receive and process inbound emails
Double Opt-in
Double opt-in subscription flow