Skip to main content

Python SDK for MailJunky - Email API with AI-Powered Workflows

Project description

MailJunky Python SDK

CI Python License

Python SDK for MailJunky - Email API with AI-Powered Workflows.

Documentation | API Reference | Get API Key

Installation

pip install mailjunky

Or with pip from GitHub:

pip install git+https://github.com/swmcc/mailjunky-python.git

Quick Start

from mailjunky import Client

client = Client(api_key="your-api-key")

client.emails.send(
    from_="hello@yourapp.com",
    to="user@example.com",
    subject="Welcome!",
    html="<h1>Welcome aboard</h1>"
)

Features

  • Emails - Send transactional emails with full control
  • Contacts - Manage contacts with tags and properties
  • Events - Track user behaviour for AI-powered workflows
  • Type hints - Full type annotations for IDE support
  • Async ready - Built on httpx for future async support

Usage

Sending Emails

from mailjunky import Client

client = Client(api_key="your-api-key")

# Simple send
client.emails.send(
    from_="hello@yourapp.com",
    to="user@example.com",
    subject="Welcome!",
    html="<h1>Welcome</h1>",
    text="Welcome"  # Plain text fallback
)

# With all options
client.emails.send(
    from_="hello@yourapp.com",
    to=["user1@example.com", "user2@example.com"],
    subject="Team Update",
    html="<h1>News</h1>",
    cc="manager@example.com",
    bcc="archive@example.com",
    reply_to="support@example.com",
    tags=["newsletter"],
    metadata={"campaign_id": "123"}
)

# Batch send
client.emails.send_batch([
    {"from": "hello@yourapp.com", "to": "a@example.com", "subject": "Hi A"},
    {"from": "hello@yourapp.com", "to": "b@example.com", "subject": "Hi B"},
])

Managing Contacts

# Create a contact
client.contacts.create(
    email="user@example.com",
    first_name="John",
    last_name="Doe",
    tags=["customer", "newsletter"]
)

# Upsert (create or update)
client.contacts.upsert(
    email="user@example.com",
    properties={"plan": "premium"}
)

# List with filters
contacts = client.contacts.list(tag="customer", limit=50)

# Update
client.contacts.update(id="contact_123", tags=["vip"])

# Delete
client.contacts.delete(id="contact_123")

Tracking Events

# Track user behaviour for AI workflows
client.events.track(
    event="purchase_completed",
    user={"email": "user@example.com"},
    properties={
        "order_id": "12345",
        "amount": 99.99,
        "items": ["SKU-001", "SKU-002"]
    }
)

Global Configuration

import mailjunky

# Configure once
mailjunky.configure(api_key="your-api-key")

# Create clients without passing api_key
client = mailjunky.Client()

Context Manager

with Client(api_key="your-api-key") as client:
    client.emails.send(...)
# Connection automatically closed

Error Handling

from mailjunky import (
    Client,
    AuthenticationError,
    ValidationError,
    RateLimitError,
    ServerError,
)

client = Client(api_key="your-api-key")

try:
    client.emails.send(...)
except AuthenticationError:
    print("Invalid API key")
except ValidationError as e:
    print(f"Invalid request: {e.message}")
    print(f"Details: {e.body}")
except RateLimitError:
    print("Slow down! Rate limit exceeded")
except ServerError:
    print("MailJunky is having issues, try again later")

Development

make install   # Install dependencies
make test      # Run tests
make lint      # Run ruff + mypy
make check     # Run all checks

License

MIT

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

mailjunky-0.1.1.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

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

mailjunky-0.1.1-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mailjunky-0.1.1.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mailjunky-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a302a4a80067ef8feffbdc208ce2ab4e1e6d297c2ac34bc75ecd85164e821f35
MD5 19186c1b83fd830cefea692e55f1472c
BLAKE2b-256 26bea9b3695d8897f959e356745a107297e9a74affbbe5d166a9571651b26ba5

See more details on using hashes here.

Provenance

The following attestation bundles were made for mailjunky-0.1.1.tar.gz:

Publisher: release.yml on swmcc/mailjunky-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 mailjunky-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: mailjunky-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mailjunky-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8a2aab49659a24e586af4f2e5ffde398b6af980e20469f72e8db23c8a222df28
MD5 0a765fcba6a671a6ef1c4cb0904fbd21
BLAKE2b-256 af2071b3e0cde8ce82d880faecbb07b11dfcd6fe50c8ee86a22a009ffed10630

See more details on using hashes here.

Provenance

The following attestation bundles were made for mailjunky-0.1.1-py3-none-any.whl:

Publisher: release.yml on swmcc/mailjunky-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