Skip to main content

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 httpx for 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

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

mailbreeze-0.1.0.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

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

mailbreeze-0.1.0-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

Details for the file mailbreeze-0.1.0.tar.gz.

File metadata

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

File hashes

Hashes for mailbreeze-0.1.0.tar.gz
Algorithm Hash digest
SHA256 502e991e12da4e5032d05981c475ab045a88f9dd690fab45ae849f764e2022f4
MD5 dbcba61d2464d16c4cb76a0f1cb950dd
BLAKE2b-256 a2bfd698823232c64c9ec9784a4cef2dee247302d67ec02412b9950da1e6ab8d

See more details on using hashes here.

Provenance

The following attestation bundles were made for mailbreeze-0.1.0.tar.gz:

Publisher: release.yml on MailBreeze/mailbreeze-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 mailbreeze-0.1.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for mailbreeze-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5850907b7b826e89658004454ccf05ae93625f0ba0b58cb81e9727d118389a5c
MD5 934f85a20613d8e47e49c76a4ba7fdee
BLAKE2b-256 0db56993386c9110a12a8f602f1a37813b68795c3e02e673dfb32f856680c164

See more details on using hashes here.

Provenance

The following attestation bundles were made for mailbreeze-0.1.0-py3-none-any.whl:

Publisher: release.yml on MailBreeze/mailbreeze-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