Skip to main content
Resend Docs

Search documentation

Type to search this documentation.

On this pageOverview

Send emails with FastAPI

Before you start, you'll need:

  1. Install

    Get the Resend Python SDK.

    Pip
    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 <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
Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu