Python SDK for MailJunky - Email API with AI-Powered Workflows
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a302a4a80067ef8feffbdc208ce2ab4e1e6d297c2ac34bc75ecd85164e821f35
|
|
| MD5 |
19186c1b83fd830cefea692e55f1472c
|
|
| BLAKE2b-256 |
26bea9b3695d8897f959e356745a107297e9a74affbbe5d166a9571651b26ba5
|
Provenance
The following attestation bundles were made for mailjunky-0.1.1.tar.gz:
Publisher:
release.yml on swmcc/mailjunky-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mailjunky-0.1.1.tar.gz -
Subject digest:
a302a4a80067ef8feffbdc208ce2ab4e1e6d297c2ac34bc75ecd85164e821f35 - Sigstore transparency entry: 1186490978
- Sigstore integration time:
-
Permalink:
swmcc/mailjunky-python@7e96ba5ea9cc8a55ac146e02994b632315b089e6 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/swmcc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7e96ba5ea9cc8a55ac146e02994b632315b089e6 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a2aab49659a24e586af4f2e5ffde398b6af980e20469f72e8db23c8a222df28
|
|
| MD5 |
0a765fcba6a671a6ef1c4cb0904fbd21
|
|
| BLAKE2b-256 |
af2071b3e0cde8ce82d880faecbb07b11dfcd6fe50c8ee86a22a009ffed10630
|
Provenance
The following attestation bundles were made for mailjunky-0.1.1-py3-none-any.whl:
Publisher:
release.yml on swmcc/mailjunky-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mailjunky-0.1.1-py3-none-any.whl -
Subject digest:
8a2aab49659a24e586af4f2e5ffde398b6af980e20469f72e8db23c8a222df28 - Sigstore transparency entry: 1186490980
- Sigstore integration time:
-
Permalink:
swmcc/mailjunky-python@7e96ba5ea9cc8a55ac146e02994b632315b089e6 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/swmcc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7e96ba5ea9cc8a55ac146e02994b632315b089e6 -
Trigger Event:
push
-
Statement type: