Skip to main content

Python SDK for mailbot, developer-first programmable email infrastructure by Mailtarget

Project description

mailbot

Python SDK source for the mailbot API.

Default API base: https://agentmail.omyop.com/v1

Current status: code is in the repository, but public package publishing is still pending.

Sync quick start

from mailbot import MailBot

client = MailBot(api_key="mb_xxx")
inbox = client.inboxes.create(username="support-bot")

Domain onboarding

domain = client.domains.create(domain="myapp.com")
print(domain["dns_records"])

verified = client.domains.verify(domain["id"])
print(verified["status"])

Async quick start

import asyncio
from mailbot import MailBot

async def main():
    async with MailBot(api_key="mb_xxx") as client:
        await client.http.arequest("GET", "/usage")

asyncio.run(main())

Webhook handling

import hmac
import hashlib

def verify_webhook(body: bytes, signature: str, secret: str) -> bool:
    expected = hmac.new(secret.encode(), body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, signature)

Compliance checking

client.compliance.check(domain="example.com")
client.compliance.readiness(inbox_id="inbox_123")

CI/email testing

result = client.messages.wait_for(
    "inbox_123",
    direction="inbound",
    subject_contains="Verify your account",
    timeout_ms=20000,
)

print(result["data"]["subject"])

Error handling

from mailbot import MailBot, AuthError, RateLimitError

client = MailBot(api_key="mb_xxx")

try:
    client.inboxes.list()
except AuthError:
    print("Invalid API key")
except RateLimitError:
    print("Too many requests")

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

mailbot_sdk-0.1.0b1.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

mailbot_sdk-0.1.0b1-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file mailbot_sdk-0.1.0b1.tar.gz.

File metadata

  • Download URL: mailbot_sdk-0.1.0b1.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for mailbot_sdk-0.1.0b1.tar.gz
Algorithm Hash digest
SHA256 a677916372319f2b0ee55830eff0f0f053870d33813db32fdec7676ddad6fa0e
MD5 88b325560294d3b9f295bd2559851f6a
BLAKE2b-256 39830d89b14f6a4af4791f16a0bbf084621fa906a4da14b9da31947d51b079d4

See more details on using hashes here.

File details

Details for the file mailbot_sdk-0.1.0b1-py3-none-any.whl.

File metadata

  • Download URL: mailbot_sdk-0.1.0b1-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for mailbot_sdk-0.1.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 4d8b0e2a72f431ea58be620d93c1ce8bf0d4a01ec6eb70016c56f96193926597
MD5 0630fe8770f9153826bcb41d665e0aa8
BLAKE2b-256 ee4a9d215a241b4c5f61d85689581e2d544af80367432176fb39b3ed7960ba92

See more details on using hashes here.

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