Skip to main content

postmark-python

Python Versions License: MIT Tests
Postmark Python SDK

The official (Beta) Python SDK for Postmark — send emails, manage bounces, templates, webhooks, and more.

For tutorials and detailed usage, check out the wiki.

For details about the Postmark API in general, see the Postmark developer docs.

Requirements

  • Python 3.10+

Installation

Install from PyPI as postmark-python (the Python package you import is still postmark):

pip install postmark-python

Quick Start

The SDK is async-first — all API calls return awaitables. As of v0.3.0, a synchronous wrapper is also available for use in non-async contexts.

Async:

import asyncio
import os

import postmark

# Tokens are read from the environment here. Optionally: pip install python-dotenv,
# then use load_dotenv() to populate os.environ from a .env file.


async def main():
    async with postmark.ServerClient(os.environ["POSTMARK_SERVER_TOKEN"]) as client:
        response = await client.outbound.send(
            {
                "sender": "sender@example.com",
                "to": "recipient@example.com",
                "subject": "Hello from Postmark",
                "text_body": "Sent with the Postmark Python SDK.",
            }
        )
        print(f"Sent: {response.message_id}")


asyncio.run(main())

Sync (v0.3.0+):

import os

import postmark.sync

with postmark.sync.ServerClient(os.environ["POSTMARK_SERVER_TOKEN"]) as client:
    response = client.outbound.send(
        {
            "sender": "sender@example.com",
            "to": "recipient@example.com",
            "subject": "Hello from Postmark",
            "text_body": "Sent with the Postmark Python SDK.",
        }
    )
    print(f"Sent: {response.message_id}")

Why sender, not from? from is a reserved keyword in Python, so the SDK uses sender for the sending address. Everything else matches the Postmark API field names directly.

Two Client Types

Client Token Use for
ServerClient Server API token Sending email, bounces, templates, stats, webhooks, streams
AccountClient Account API token Domains, sender signatures, managing servers, data removals
import postmark

# Use as async context managers to ensure connections are closed
async with postmark.ServerClient(os.environ["POSTMARK_SERVER_TOKEN"]) as client:
    ...

async with postmark.AccountClient(os.environ["POSTMARK_ACCOUNT_TOKEN"]) as account:
    ...

# Or call close() explicitly when done
client = postmark.ServerClient(os.environ["POSTMARK_SERVER_TOKEN"])
await client.close()

Django

postmark.django.EmailBackend is a drop-in EMAIL_BACKEND for Django's django.core.mail, supporting Django 4.2 LTS through 6.1. Requires the django extra:

pip install postmark-python[django]
# settings.py
EMAIL_BACKEND = "postmark.django.EmailBackend"
POSTMARK_SERVER_TOKEN = "your-server-token"

See the Django Backend wiki page and examples/django/ for tags, metadata, attachments, and signals.

Development

git clone https://github.com/ActiveCampaign/postmark-python.git
cd postmark-python
poetry install
poetry run pre-commit install
# Run tests
poetry run pytest

# Lint and type-check
poetry run pre-commit run --all-files

Contributing

See CONTRIBUTING.md for setup, testing, and PR guidelines.

Support

License

MIT — see LICENSE.

Metadata

Release files for postmark-python 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for postmark-python 0.5.0
File Size Uploaded Provenance Actions
postmark_python-0.5.0.tar.gz 39.6 kB With provenance Details for postmark_python-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for postmark-python 0.5.0
File Interpreter ABI Platform Actions
postmark_python-0.5.0-py3-none-any.whl Python 3 none any Details for postmark_python-0.5.0-py3-none-any.whl

Total release size: 102.9 kB

Release files / postmark_python-0.5.0.tar.gz

Download URL postmark_python-0.5.0.tar.gz
Size 39.6 kB
Tags Source
SHA-256 checksum
How to use checksums
5cb721d44d76bb7ae14b7f1dea24026dc1e7ca69fceab4686c5803f396905e4f
BLAKE2b-256 checksum
How to use checksums
509ffcfa33fd4db008310fc79291babe0a9fce309f71dd9f66447e83626559bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Release files / postmark_python-0.5.0-py3-none-any.whl

Download URL postmark_python-0.5.0-py3-none-any.whl
Size 63.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7ad711973422a29de3222db2fc01022af71544e7848fc9b99e1ebba3e41e7170
BLAKE2b-256 checksum
How to use checksums
03c0d879bd4c1005bca58dd99bd16abac9eec251d77eaea7f7917566c0b2e3b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Security for postmark-python 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for postmark_python-0.5.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page