MailJunky Python SDK
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
Metadata
Release files for mailjunky 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mailjunky-0.1.1.tar.gz | 12.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mailjunky-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.9 kB
Release files / mailjunky-0.1.1.tar.gz
| Download URL | mailjunky-0.1.1.tar.gz |
|---|---|
| Size | 12.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a302a4a80067ef8feffbdc208ce2ab4e1e6d297c2ac34bc75ecd85164e821f35
|
|
BLAKE2b-256 checksum How to use checksums |
26bea9b3695d8897f959e356745a107297e9a74affbbe5d166a9571651b26ba5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 26, 2026.
Transparency logRelease files / mailjunky-0.1.1-py3-none-any.whl
| Download URL | mailjunky-0.1.1-py3-none-any.whl |
|---|---|
| Size | 11.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8a2aab49659a24e586af4f2e5ffde398b6af980e20469f72e8db23c8a222df28
|
|
BLAKE2b-256 checksum How to use checksums |
af2071b3e0cde8ce82d880faecbb07b11dfcd6fe50c8ee86a22a009ffed10630
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 26, 2026.
Transparency log