Skip to main content

A minimal Python client for the Postmark API

Project description

Postiee

A minimal Python client for the Postmark API.

Installation

pip install postiee

Quick Start

from postiee import PostieClient

# Initialize client
client = PostieClient(server_token="your-postmark-server-token")

# Send a simple email
response = client.send_email(
    from_email="support@nomadicinfluence.com",
    to="user@example.com",
    subject="Hello from Postiee",
    html_body="<h1>Hello!</h1><p>This is a test email.</p>",
    text_body="Hello! This is a test email."
)

print(response)

Features

  • ✅ Send single emails
  • ✅ Send batch emails (up to 500)
  • ✅ Send template-based emails
  • ✅ HTML and plain text support
  • ✅ CC, BCC, Reply-To
  • ✅ Email tagging and metadata
  • ✅ Open and link tracking
  • ✅ Type hints
  • ✅ Minimal dependencies (only requests)

Usage

Send Email

client.send_email(
    from_email="support@nomadicinfluence.com",
    to="user@example.com",
    subject="Welcome!",
    html_body="<h1>Welcome to our platform</h1>",
    text_body="Welcome to our platform",
    tag="onboarding",
    track_opens=True
)

Send Batch Emails

emails = [
    {
        "From": "support@nomadicinfluence.com",
        "To": "user1@example.com",
        "Subject": "Hello User 1",
        "HtmlBody": "<p>Hello User 1</p>"
    },
    {
        "From": "support@nomadicinfluence.com",
        "To": "user2@example.com",
        "Subject": "Hello User 2",
        "HtmlBody": "<p>Hello User 2</p>"
    }
]

responses = client.send_batch(emails)

Send Template Email

client.send_template_email(
    from_email="support@nomadicinfluence.com",
    to="user@example.com",
    template_id=123456,
    template_model={
        "name": "John Doe",
        "action_url": "https://example.com/verify"
    }
)

Django Integration

Option 1: Use Django Email Backend (Recommended)

Configure Postiee as your Django email backend:

# settings.py
EMAIL_BACKEND = 'postiee.django_backend.PostieEmailBackend'
POSTMARK_SERVER_TOKEN = os.getenv('POSTMARK_SERVER_TOKEN')
DEFAULT_FROM_EMAIL = 'support@nomadicinfluence.com'

Then use Django's standard email functions:

from django.core.mail import send_mail, EmailMultiAlternatives

# Simple email
send_mail(
    subject='Welcome!',
    message='Welcome to our platform',
    from_email='support@nomadicinfluence.com',
    recipient_list=['user@example.com'],
)

# HTML email
email = EmailMultiAlternatives(
    subject='Welcome!',
    body='Welcome to our platform',
    from_email='support@nomadicinfluence.com',
    to=['user@example.com'],
)
email.attach_alternative('<h1>Welcome!</h1>', "text/html")
email.send()

Option 2: Use PostieClient Directly

# utils/email.py
from postiee import PostieClient
from django.conf import settings

postmark = PostieClient(server_token=settings.POSTMARK_SERVER_TOKEN)

def send_welcome_email(user_email, user_name):
    postmark.send_email(
        from_email="support@nomadicinfluence.com",
        to=user_email,
        subject=f"Welcome {user_name}!",
        html_body=f"<h1>Welcome {user_name}!</h1>",
        text_body=f"Welcome {user_name}!"
    )

Error Handling

from postiee import PostieClient, PostieAPIError, PostieError

try:
    client.send_email(...)
except PostieAPIError as e:
    print(f"API Error: {e}")
    print(f"Error Code: {e.error_code}")
    print(f"Status Code: {e.status_code}")
except PostieError as e:
    print(f"Client Error: {e}")

Requirements

  • Python 3.7+
  • requests

License

MIT

Contributing

Contributions welcome! Please open an issue or PR.

Links

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

postiee-0.1.1.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

postiee-0.1.1-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file postiee-0.1.1.tar.gz.

File metadata

  • Download URL: postiee-0.1.1.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.0 CPython/3.14.2 Darwin/25.2.0

File hashes

Hashes for postiee-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e1034232a8e5764ac923e62d2ccd851fa1be2f95f30ad8cb378619de6c19bcb6
MD5 abf5fefdb6b2dc09bea7f57a4e3c3450
BLAKE2b-256 668765e23f6fe63429687c6e71af6c14447ba9b93160646b061e4b0e332a7088

See more details on using hashes here.

File details

Details for the file postiee-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: postiee-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.0 CPython/3.14.2 Darwin/25.2.0

File hashes

Hashes for postiee-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 165d20525020fff8d1c7a8aa64304438b1645b3cbd6fab22568682126354880a
MD5 ed008dc28e212a5676971635ca98d781
BLAKE2b-256 4239f1aec27f874c785f7f14472e909e90407a969a00d71cbd95c8d6886caa7d

See more details on using hashes here.

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