New to the Lettr Python SDK? Start with the Python Quickstart to learn the basics, then return here for Flask-specific integration patterns.
Prerequisites
Before you begin, make sure you have: You’ll also need:- Python 3.8 or later installed
- Flask web framework
- A verified sending domain in your Lettr dashboard
Quick Setup
Get started in three quick steps: install dependencies, configure Flask, and send.Install dependencies
Flask Application Structure
For production applications, organize your code with a proper structure:Configuration
Create aconfig.py file for application configuration:
Email Service
Create an email service inservices/email.py:
Application Factory
Create an application factory inapp.py:
Routes
Create authentication routes inroutes/auth.py:
Advanced Features
Using Templates
Send emails using Lettr-managed templates:Background Task Queue with Celery
For production applications, send emails asynchronously using Celery:tasks.py:
Error Handling
Implement error handling in your routes:See Error Handling in the Python Quickstart for comprehensive error handling patterns.