sendsend.email

Send email with Flask

A server-side call to the SendSend API from your Flask app.

  1. Create a test API key in the dashboard first: it never delivers real email. Switch to a live key once your domain is verified.
  2. Set SENDSEND_API_KEY in the environment that runs Flask.
  3. Add this to app.py:
import os, uuid, requests
from flask import Flask, jsonify, request

app = Flask(__name__)

@app.post("/send")
def send():
    r = requests.post(
        "https://api.sendsend.email/v1/emails",
        headers={"Authorization": f"Bearer {os.environ['SENDSEND_API_KEY']}", "Idempotency-Key": str(uuid.uuid4())},
        json={"from": "Acme <hello@mail.acme.com>", "to": [request.json["to"]], "subject": "Hello from Flask", "html": "<p>It works!</p>"},
        timeout=15,
    )
    return jsonify(r.json()), r.status_code

Good to know