The Official Postmark Python SDK.
Actively maintained. Last release 5 weeks ago, commits in 12 of the last 26 weeks. A safe choice.
pip install postmark-python
postmark-python |
|
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+):