Skip to main content

Official Python SDK for Mail.td — temp mail API, email testing, and SMTP sandbox for developers

Project description

mailtd

PyPI version PyPI downloads License: MIT

Official Python SDK for Mail.td — the developer email platform for temp mail, email testing, and SMTP sandbox.

  • Temp Mail API — Create and manage temporary email addresses programmatically
  • Email Testing — Receive, inspect, and verify emails in your test suite
  • SMTP Sandbox — Capture outbound emails in a safe sandbox environment without sending to real inboxes
  • Webhooks — Get notified in real-time when emails arrive
  • Custom Domains — Use your own domain for branded temporary mailboxes

Install

pip install mailtd

Requires Python 3.9+.

Quick Start

from mailtd import MailTD

client = MailTD("td_...")

# Create a temporary email address
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)

Use Cases

  • Automated testing — Create temp mail addresses in CI/CD to test signup flows, OTP verification, and transactional emails
  • Email verification testing — Validate that your app sends the right emails with the right content
  • SMTP sandbox — Route your app's outbound SMTP to Mail.td sandbox to inspect emails without spamming real users
  • QA environments — Give each test run its own mailbox, then tear it down

Authentication

All API calls require a Pro API Token (td_...). Pass it when creating the client:

# With a token string
client = MailTD("td_...")

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

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

Resources

Accounts

domains = client.accounts.list_domains()
account = client.accounts.create("user@mail.td", password="pass123")
info = client.accounts.get(account_id)
client.accounts.reset_password(account_id, password="newpass")
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()

User (Pro)

me = client.user.get_me()
accounts = client.user.list_accounts()
client.user.delete_account(account_id)
client.user.reset_account_password(account_id, password="newpass")
messages, page = client.user.list_account_messages(account_id)

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_taken"

Links

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.3.2.tar.gz (9.4 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.3.2-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for mailtd-1.3.2.tar.gz
Algorithm Hash digest
SHA256 78c0b9cf115546aad7799f37d155f112217ecedc035507a761c23b1f8fddd4b5
MD5 7a67adf5b4dc23fbaa3c4ac945250230
BLAKE2b-256 b95aa24842bc82d3dd40dd58eea5015bbb31b5479677ba5e6b5218dc7f40b7e6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mailtd-1.3.2-py3-none-any.whl
  • Upload date:
  • Size: 11.7 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.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1c37991fc6af2a27e85fb137c86f108db8a18a2d1ee89936b5f491877931076c
MD5 5e19df6b2187248695ec556fefac029d
BLAKE2b-256 8b3a0d8170c99552a7fda94431447211e4fb37ed291f7672b337ae05fe766e29

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