All guides
Send Email from Flask
Send emails from Flask routes and blueprints
1. Install the SDK
pip install sendpigeon2. Set your API key
Add your SendPigeon API key to your environment variables:
SENDPIGEON_API_KEY=your_api_key_hereGet your API key from the dashboard.
3. Send your first email
import os
from flask import Flask, request, jsonify
from sendpigeon import SendPigeon
app = Flask(__name__)
client = SendPigeon(os.environ["SENDPIGEON_API_KEY"])
@app.route("/contact", methods=["POST"])
def contact():
data = request.get_json()
client.send(
to=data["email"],
from_email="hello@yourdomain.com",
subject=f"Thanks for reaching out, {data['name']}!",
html="<h1>We got your message</h1><p>We'll get back to you soon.</p>",
)
return jsonify({"success": True})
if __name__ == "__main__":
app.run()Features
- Simple Flask integration
- Works with blueprints
- Deploy anywhere Python runs
Ready to send emails?
Get started with 1,000 free emails per month.
Start for free