Skip to main content

Official Python SDK for the Mail.td developer email platform

Project description

mailtd

Official Python SDK for the Mail.td developer email platform.

Install

pip install mailtd

Requires Python 3.9+.

Quick Start

from mailtd import MailTD

client = MailTD("tm_pro_...")

# Create a mailbox
account = client.accounts.create("test@mail.td", password="mypassword")

# List messages
messages, page = client.messages.list(account.id)

# Get a message
msg = client.messages.get(account.id, messages[0].id)
print(msg.subject, msg.text_body)

Authentication

# With a Pro API token
client = MailTD("tm_pro_...")

# With custom base URL
client = MailTD("tm_pro_...", base_url="https://api.mail.td")

# As context manager
with MailTD("tm_pro_...") as client:
    messages, _ = client.messages.list(account_id)

Resources

Accounts

domains = client.accounts.list_domains()
account = client.accounts.create("user@mail.td", password="pass123")
result = client.accounts.login("user@mail.td", password="pass123")
info = client.accounts.get(account_id)
client.accounts.delete(account_id)

Messages

messages, page = client.messages.list(account_id)
msg = client.messages.get(account_id, message_id)
eml = client.messages.get_source(account_id, message_id)
attachment = client.messages.get_attachment(account_id, message_id, 0)
client.messages.mark_as_read(account_id, message_id)
count = client.messages.batch_mark_as_read(account_id, all=True)
client.messages.delete(account_id, message_id)

Domains (Pro)

domains = client.domains.list()
result = client.domains.create("example.com")
status = client.domains.verify(domain_id)
client.domains.delete(domain_id)

Webhooks (Pro)

webhook = client.webhooks.create("https://example.com/hook", events=["email.received"])
deliveries = client.webhooks.list_deliveries(webhook.id)
secret = client.webhooks.rotate_secret(webhook.id)
client.webhooks.delete(webhook.id)

Sandbox (Pro)

info = client.sandbox.get_info()
messages, page = client.sandbox.list_messages()
msg = client.sandbox.get_message(message_id)
deleted = client.sandbox.purge_messages()

Tokens (Pro)

result = client.tokens.create("CI Token")
tokens = client.tokens.list()
client.tokens.revoke(token_id)

Billing (Pro)

status = client.billing.get_status()
client.billing.cancel()
client.billing.resume()
url = client.billing.get_portal_url()

Error Handling

from mailtd import MailTD, APIError

try:
    client.accounts.create("taken@mail.td", password="...")
except APIError as e:
    print(e.status)  # 409
    print(e.code)    # "address_already_exists"

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

mailtd-1.0.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

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

mailtd-1.0.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file mailtd-1.0.0.tar.gz.

File metadata

  • Download URL: mailtd-1.0.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for mailtd-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f49fbdaec0a2d9ed489562af1f2c756f1c22c607a5208f6c0aeae0a5864a4cb3
MD5 d04a3d716b8c72d4df50cde6f1336897
BLAKE2b-256 bb133a54bda59be54e575c2ae36887083c03c02d86d4cb4b872e9710dc2d7272

See more details on using hashes here.

File details

Details for the file mailtd-1.0.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for mailtd-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 20cba628ca7e70060be6ef4e136cf5362fc3d4412f1c04d3ce8aa1897de0d3ae
MD5 53d7d92424428a12d90cb4543776dce5
BLAKE2b-256 5509553145d8c260d53265747ee0fa1014ae0ebb67b3fed4bd3144c9e33cd2e0

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