Skip to main content

Prerequisites

To get the most out of this guide, you’ll need to:

1. Install

Get the Resend Python SDK.
pip install resend

2. Send email using HTML

The easiest way to send an email is by using the html parameter.
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 <[email protected]>",
        "to": ["[email protected]"],
        "subject": "hello world",
        "html": "<strong>it works!</strong>",
    }
    email: resend.Emails.SendResponse = resend.Emails.send(params)
    return email

3. Try it yourself

FastAPI Example

See the full source code.