Skip to main content

Prerequisites

To get the most out of this guide, you’ll need to:
You can find your API keys in your SendPost Dashboard. Make sure to use your Sub-Account API Key for sending emails.

1. Install Dependencies

pip

2. Environment Setup

Create a .env file:

3. Basic Flask App Setup

Create app.py:
Python

4. Create Email Utility

Create utils/email_service.py:
Python

5. Send Your First Email

Simple Route

Python

6. Common Use Cases

Welcome Email Route

Python

Password Reset Email

Python

7. Using Blueprints

Create blueprints/email_bp.py:
Python
Register in app.py:
Python

8. Error Handling

Create errors.py:
Python
Use in app.py:
Python

9. Using Flask-Mail Style Interface (Optional)

Create extensions/email.py:
Python
Use it:
Python
Make sure your sender email domain is verified in your SendPost account before sending emails.

10. Next Steps

Explore more examples and use cases:

Flask Documentation

Learn more about Flask framework

SendPost Python SDK

View the official SDK package on PyPI

Quickstart Example

View a complete working example on GitHub