Skip to main content
July 2026

Python SDK

A typed, sync and async Python client for sending mail, scheduling sends, and verifying webhooks. Built for Python 3.12+.

Python SDK

What it does

mailkube is the official Python client library. Install it with pip install mailkube or uv add mailkube, set an API key, and send your first message in a few lines. It ships fully typed, requires Python 3.12+, and is Apache-2.0 licensed.

Key benefits

  • Sync or async, same client shape. Mailkube and AsyncMailkube share an identical method surface, so moving a codebase from sync to async is a client swap, not a rewrite.
  • Scheduled sends built in. Pass scheduled_at on emails.send, then manage the queue with client.scheduled_emails, including batch reschedule and cancel through a shared batch_id.
  • Webhook verification with no framework glue. mailkube.verify(raw_body, headers, signing_secret) is a pure stdlib helper that works the same whether the receiver is Flask, FastAPI, or something custom.
  • Safe to retry. An idempotency_key on every send means a retried request after a timeout can’t double-send, and a typed error hierarchy makes failures easy to branch on.

Getting started

  1. Install the SDK: pip install mailkube
  2. Set your API key as MAILKUBE_API_KEY, or pass api_key= to the client
  3. Send a first message:
from mailkube import Mailkube

with Mailkube() as client:
    email = client.emails.send(
        from_="Acme <hello@yourdomain.com>",
        to="customer@example.com",
        subject="Hello world",
        html="<p>It works!</p>",
    )
    print("sent:", email.id)
  1. Verify an inbound webhook with mailkube.verify(...)
  2. Read the Python SDK docs for templates, attachments, tags, and the full error reference