Python
FastAPI
Learn how to send emails in FastAPI using Dhesend Python SDK.
Prerequisites
To get the most out of this guide, you’ll need to:
2. Send email using html
The easiest way to send an email is by using the html parameter.
1from fastapi import FastAPI
2from dhesend import Dhesend, SendEmailPayload
3
4app = FastAPI()
5
6@app.post("/send-email")
7def send_email():
8 dhesend = Dhesend("your-apikey")
9
10 params: SendEmailPayload = {
11 "from": "Dhesend <example@domain.com>",
12 "to": ["example@dhesend.com"],
13 "subject": "Welcome to Dhesend",
14 "htmlBody": "<strong>Have a nice day!</strong>",
15 }
16
17 response = dhesend.Email.send(params)
18 return responseOn this page