Official Python SDK for MailBreeze email platform
Project description
MailBreeze Python SDK
The official Python SDK for the MailBreeze email platform.
Features
- Full async support - Built on
httpxfor modern async/await patterns - Type-safe - Complete type hints with Pydantic models
- Automatic retries - Built-in retry logic with exponential backoff
- Python 3.10+ - Modern Python with native type syntax
Installation
pip install mailbreeze
Quick Start
import asyncio
from mailbreeze import MailBreeze
async def main():
client = MailBreeze(api_key="sk_live_xxx")
# Send an email
result = await client.emails.send(
from_="hello@yourdomain.com",
to="user@example.com",
subject="Welcome!",
html="<h1>Welcome to our platform!</h1>",
)
print(result.id)
asyncio.run(main())
Resources
Emails
# Send an email
result = await client.emails.send(
from_="hello@yourdomain.com",
to="user@example.com",
subject="Hello",
html="<p>Hello World!</p>",
)
# Send with a template
result = await client.emails.send(
from_="hello@yourdomain.com",
to=["user1@example.com", "user2@example.com"],
template_id="welcome-template",
variables={"name": "John", "plan": "Pro"},
)
# List emails
emails = await client.emails.list(status="delivered", page=1, limit=20)
# Get email details
email = await client.emails.get("email_xxx")
# Get statistics
stats = await client.emails.stats()
Contact Lists
# Create a list
list_ = await client.lists.create(
name="Newsletter Subscribers",
description="Weekly newsletter recipients",
)
# List all lists
lists = await client.lists.list()
# Get list stats
stats = await client.lists.stats("list_xxx")
Contacts
# Get contacts for a list
contacts = client.contacts("list_xxx")
# Create a contact
contact = await contacts.create(
email="user@example.com",
first_name="John",
last_name="Doe",
custom_fields={"company": "Acme Inc"},
)
# List contacts
result = await contacts.list(status="active", page=1, limit=50)
# Update a contact
updated = await contacts.update("contact_xxx", first_name="Jane")
# Delete a contact
await contacts.delete("contact_xxx")
Email Verification
# Verify a single email
result = await client.verification.verify("user@example.com")
print(result.is_valid) # True
# Batch verification
batch = await client.verification.batch(
emails=["user1@example.com", "user2@example.com"]
)
# Check batch status
status = await client.verification.get(batch.verification_id)
Automations
# Enroll a contact
enrollment = await client.automations.enroll(
automation_id="auto_welcome",
contact_id="contact_xxx",
variables={"coupon_code": "WELCOME10"},
)
# List enrollments
enrollments = await client.automations.enrollments.list(status="active")
# Cancel an enrollment
await client.automations.enrollments.cancel("enroll_xxx")
Error Handling
from mailbreeze import (
MailBreeze,
MailBreezeError,
AuthenticationError,
ValidationError,
NotFoundError,
RateLimitError,
ServerError,
)
try:
await client.emails.send(...)
except ValidationError as e:
print(f"Validation failed: {e.message}")
print(f"Details: {e.details}")
except AuthenticationError:
print("Invalid API key")
except RateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after} seconds")
except NotFoundError:
print("Resource not found")
except ServerError as e:
print(f"Server error: {e.status_code}")
except MailBreezeError as e:
print(f"API error: {e.code} - {e.message}")
Requirements
- Python 3.10 or higher
- A MailBreeze API key (get one here)
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
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 mailbreeze-0.2.0.tar.gz.
File metadata
- Download URL: mailbreeze-0.2.0.tar.gz
- Upload date:
- Size: 20.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f5706a4c927fba8302ee12aac18dd5bd0d4546b0e514f497625348ff6e55170
|
|
| MD5 |
afdfa46a43ac0cabfdcb780808c1e526
|
|
| BLAKE2b-256 |
57358a9b6c3f41146a69561515ddd7098723802bbd129fd56f65300396750eed
|
Provenance
The following attestation bundles were made for mailbreeze-0.2.0.tar.gz:
Publisher:
release.yml on MailBreeze/mailbreeze-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mailbreeze-0.2.0.tar.gz -
Subject digest:
2f5706a4c927fba8302ee12aac18dd5bd0d4546b0e514f497625348ff6e55170 - Sigstore transparency entry: 779931798
- Sigstore integration time:
-
Permalink:
MailBreeze/mailbreeze-python@2a8f9227bd18b33c398656ad53c7d5ac720f4bfb -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/MailBreeze
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2a8f9227bd18b33c398656ad53c7d5ac720f4bfb -
Trigger Event:
push
-
Statement type:
File details
Details for the file mailbreeze-0.2.0-py3-none-any.whl.
File metadata
- Download URL: mailbreeze-0.2.0-py3-none-any.whl
- Upload date:
- Size: 19.8 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 |
9749cf10e8b767813cc36d767f997cdd830d820bdc4ac0151a661a5e54319e7f
|
|
| MD5 |
ae80e90d43252a05ecdd0d18f2384754
|
|
| BLAKE2b-256 |
26aecfe33d1905e9ad223d1fd8cc9c4bd4dc179bf8171f0476cc2cff9a8e7c23
|
Provenance
The following attestation bundles were made for mailbreeze-0.2.0-py3-none-any.whl:
Publisher:
release.yml on MailBreeze/mailbreeze-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mailbreeze-0.2.0-py3-none-any.whl -
Subject digest:
9749cf10e8b767813cc36d767f997cdd830d820bdc4ac0151a661a5e54319e7f - Sigstore transparency entry: 779931802
- Sigstore integration time:
-
Permalink:
MailBreeze/mailbreeze-python@2a8f9227bd18b33c398656ad53c7d5ac720f4bfb -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/MailBreeze
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2a8f9227bd18b33c398656ad53c7d5ac720f4bfb -
Trigger Event:
push
-
Statement type: