GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - ActiveCampaign/postmark-python: The official Postmark Python SDK

BranchesTags
Open more actions menu

Latest commit

 

History

84 Commits
84 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
.vscode
.vscode
 
 
examples
examples
 
 
postmark
postmark
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
.pre-commit-config.yaml
.pre-commit-config.yaml
 
 
.secrets.baseline
.secrets.baseline
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
SECURITY.md
SECURITY.md
 
 
example.env
example.env
 
 
poetry.lock
poetry.lock
 
 
postmark_python_sdk.png
postmark_python_sdk.png
 
 
pyproject.toml
pyproject.toml
 
 
pytest.ini
pytest.ini
 
 

Repository files navigation

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+

Security: the Brotli decoder is affected by CVE-2026-111497. httpx requests and decodes Brotli only when the optional brotli or brotlicffi package is installed. If you have either, use brotli >= 1.2.1 or brotlicffi >= 1.2.1.0.

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": "[email protected]",
                "to": "[email protected]",
                "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": "[email protected]",
            "to": "[email protected]",
            "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

  • Issues: GitHub Issues
  • Postmark Support: [email protected]

License

MIT — see LICENSE.

About

The official Postmark Python SDK

postmarkapp.com

Topics

djangodjango-emaildjango-emailtoolsemailpostmarkpythonsdktransactional-email

Resources

Readme
MIT license

Contributing

Contributing

Security policy

Security policy
Activity
Custom properties

Stars

16 stars

Watchers

0 watching

Forks

5 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.