Skip to main content

The Official Postmark Python SDK.

Project description

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 fully async. All API calls must be awaited.

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())

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()

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

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for your changes
  4. Ensure all checks pass (poetry run pre-commit run --all-files)
  5. Open a Pull Request

Support

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

postmark_python-0.2.3.tar.gz (31.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

postmark_python-0.2.3-py3-none-any.whl (53.8 kB view details)

Uploaded Python 3

File details

Details for the file postmark_python-0.2.3.tar.gz.

File metadata

  • Download URL: postmark_python-0.2.3.tar.gz
  • Upload date:
  • Size: 31.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for postmark_python-0.2.3.tar.gz
Algorithm Hash digest
SHA256 c29cb4db917ec8987838649cf3d38d4e1b4dc6991ba8be34f054a9886beccb39
MD5 ce3d72753d9850690a09c8b62b2bfb43
BLAKE2b-256 1b01f86dbbe656e3e13e7623d8698f1458b98e8ffb70bbbc379fbac408a79a7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for postmark_python-0.2.3.tar.gz:

Publisher: publish.yml on ActiveCampaign/postmark-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file postmark_python-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: postmark_python-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 53.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for postmark_python-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f361511db7e647cf7f10bba620a48bd3f6aafee2eab534aa1abfb547b7403c42
MD5 11b4e184b3ac536b6b7719da08ae4d42
BLAKE2b-256 c3fa3fbb821aae0d96aec233b3f0e933aa797fef725244f3105592bce71e4b46

See more details on using hashes here.

Provenance

The following attestation bundles were made for postmark_python-0.2.3-py3-none-any.whl:

Publisher: publish.yml on ActiveCampaign/postmark-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page