Skip to content

Send Emails with Python

Learn how to send transactional emails using PostStack and Python.

1. Install the SDK

bash
pip install poststack

2. Initialize the client

python
from poststack import PostStack

ps = PostStack(api_key="sk_live_...")

3. Send an email

python
from poststack import PostStack, PostStackError

ps = PostStack(api_key="sk_live_...")

try:
    result = ps.emails.send({
        "from": "hello@yourdomain.com",
        "to": ["user@example.com"],
        "subject": "Hello from Python!",
        "html": "<h1>Welcome!</h1>",
    })
    print(result["id"])
except PostStackError as e:
    print(f"API error {e.status_code}: {e.message}")

Notes

  • Official Python SDK — wraps the REST API with typed resource modules
  • Requires Python 3.9+

Ready to send emails with Python?

Create a free account and get your API key in under a minute.