Minimal setup & reliable delivery
Add email sending to your FastAPI application in minutes with Sidemail's official Python SDK and developer‑first API. Sidemail handles deliverability, email design, and infrastructure so you can integrate reliable email sending into your FastAPI routes with minimal code.
Get startedRead API docsfrom fastapi import FastAPI, Request
from services import sidemail
app = FastAPI()
@app.post("/register")
def register(request: Request, data: dict):
# ... create user
sidemail.send_email(
to_address=data["email"],
from_address="[email protected]",
from_name="Your App",
template_name="Welcome",
template_props={"firstName": data["name"]},
)
return {"status": "registered"}Start sending emails from your FastAPI application in three steps:
Add Sidemail to your FastAPI project via pip:
pip install sidemailCreate a services.py module and initialize the Sidemail client. The SDK reads SIDEMAIL_API_KEY from your environment automatically.
# services.py
from sidemail import Sidemail
sidemail = Sidemail()Import the client and call send_email in any FastAPI route handler. Pass the recipient, sender, and template or content. That's it.
from fastapi import FastAPI
from services import sidemail
app = FastAPI()
@app.post("/register")
def register(data: dict):
# ... create user
sidemail.send_email(
to_address=data["email"],
from_address="[email protected]",
from_name="Your App",
template_name="Welcome",
template_props={"firstName": data["name"]},
)
return {"status": "registered"}Key features & perks
With Sidemail, you can send any transactional email from FastAPI. Here are a few examples with code:
# FastAPI: Send an account verification email
from fastapi import FastAPI
from services import sidemail
app = FastAPI()
@app.post("/register")
def register(data: dict):
# ... create user, generate token
sidemail.send_email(
to_address=data["email"],
from_address="[email protected]",
from_name="Your App",
template_name="Email Verification",
template_props={
"verifyUrl": f"https://yourapp.com/verify?token={token}",
},
)
return {"status": "registered"}Send a sign-up verification email with a one-time link or code to confirm the user's email address.
# FastAPI: Send a payment receipt email
from datetime import date
from services import sidemail
sidemail.send_email(
to_address=user["email"],
from_address="[email protected]",
from_name="Your App",
template_name="Payment Receipt",
template_props={
"userName": user["name"],
"amount": "$19.99",
"date": date.today().strftime("%b %d, %Y"),
},
)Send a receipt, invoice, or other notification to your user.
template_props to populate Sidemail's receipt and invoice templates.# FastAPI: Schedule a welcome email for 1 hour from now
from datetime import datetime, timedelta, timezone
from services import sidemail
scheduled_time = datetime.now(timezone.utc) + timedelta(hours=1)
sidemail.send_email(
to_address="[email protected]",
from_address="[email protected]",
from_name="Your App",
template_name="Welcome",
template_props={"firstName": "Alex"},
scheduled_at=scheduled_time.isoformat(),
)Schedule a welcome email to deliver later, for example one hour after registration.
scheduled_at field with an ISO timestamp to control exactly when the email is sent.# FastAPI: Send a password reset email with Markdown
from pathlib import Path
from services import sidemail
markdown = Path("templates/emails/password-reset.md").read_text()
sidemail.send_email(
to_address="[email protected]",
markdown=markdown,
template_props={
"firstName": "Alex",
"resetLink": "https://yourapp.com/reset?token=abc123xyz",
"expiresIn": "30 minutes",
},
)---
subject: "Reset your password"
fromAddress: "[email protected]"
fromName: "Your App Security"
---
Hi {firstName}, we received a request to reset your password.
[$btn Reset password]({resetLink})
This link expires in {expiresIn}.Sidemail's API lets you author email content in Markdown, which is automatically transformed into pixel‑perfect, responsive emails that look great in every inbox and on every device. Each email is branded with your logo and styled to match your project's email design.
.md file in your project's templates directorytemplate_props(such as resetLink and expiresIn), which map directly to variables in your markdown.Deliverability best practices
SPF and DKIM are authentication protocols that prove your emails are legitimately sent from your domain. DMARC builds on both by telling mail servers how to handle messages that fail those checks. Together, they are 3 critical factors for inbox delivery and sender reputation.
Sidemail automatically handles SPF, DKIM, and DMARC configuration for you, so your FastAPI application sends authenticated, best‑practice‑compliant emails from the start.




The simplest way to build emails
Sidemail's no‑code email editor is the fastest way to create responsive email templates that display correctly across every client and device. No HTML knowledge required. Add your logo and brand colors, and you're ready to send.
Need to ship faster? Sidemail includes a library of production‑ready templates for the most common use cases – password resets, welcome emails, receipts, and more. Build from scratch or customize a premade template — we guarantee your emails look great everywhere.
Learn moreDeveloper‑friendly formatting
Writing and maintaining HTML emails by hand is tedious, especially when you just want to send clean, readable content.
Sidemail lets you author your email body in Markdown and automatically converts it into a responsive, well‑styled HTML email. You get smart formatting – headings, lists, links, and code blocks – without stressing about broken layouts or cross‑client rendering issues.
Perfect for transactional emails sent from your FastAPI routes – clean content, fast authoring, and zero HTML to debug.
Learn more
Ready to send transactional emails from your FastAPI app? With Sidemail, you can integrate in under 30 minutes and deliver emails reliably.
Start free trialThe simplest way to send email from a FastAPI app is by using an email API like Sidemail. Install the Python SDK (pip install sidemail), create a shared service module, and call sidemail.send_email() from any route handler. No SMTP server or third-party mailer dependency needed. Sidemail manages authentication, formatting, and deliverability for you.
Sidemail's Python SDK is synchronous, so use regular def route handlers for email‑sending endpoints. FastAPI automatically runs sync route functions in a thread pool, so they won't block the event loop. If you want non‑blocking delivery in an async def route, use FastAPI's BackgroundTasks to offload the call.
Instead of rendering HTML yourself, use Sidemail's template system. In the Sidemail dashboard, pick a premade template or build one with the drag‑and‑drop editor. In your FastAPI route, reference the template by template_name and pass dynamic data via template_props. Sidemail merges the data and returns a well‑formatted email.
Yes. FastAPI's BackgroundTasks feature works great with Sidemail. Add a background task that calls sidemail.send_email() and the email will be sent after the response is returned to the client. This is the recommended approach for keeping endpoint latency low without setting up a task queue.
No. Sidemail is an API‑based email service, so there's no SMTP server to configure or maintain. The Python SDK makes simple HTTPS calls to the Sidemail API. Just install the package, set your API key, and you're ready to send.
Wrap your sidemail.send_email() call in a try/except block and catch sidemail.SidemailError. The exception includes the HTTP status code, error type, and a clear message. Log it using Python's logging module and return an appropriate HTTP response to the client, or use FastAPI's HTTPException for structured error responses.