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("td_...")
# 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
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"
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.1.tar.gz
(7.9 kB
view details)
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
mailtd-1.3.1-py3-none-any.whl
(11.0 kB
view details)
File details
Details for the file mailtd-1.3.1.tar.gz.
File metadata
- Download URL: mailtd-1.3.1.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce4caed9db35ad55271fdc1b0749473d20844a97078f1c770c6890b667e567bd
|
|
| MD5 |
2d82b7124bde212c2fabc37723c70b84
|
|
| BLAKE2b-256 |
03b9a5f609c60235f81260d631b07806c4763fd850b5c580613e5af873be4726
|
File details
Details for the file mailtd-1.3.1-py3-none-any.whl.
File metadata
- Download URL: mailtd-1.3.1-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
092fbe1bfade566004a5091cdbed945805da93d47053202ea9c1d75ad6bf0b7c
|
|
| MD5 |
9a2fba6fd8f840683f1afb5403512084
|
|
| BLAKE2b-256 |
3f3f20cc1a2ac973984878242724e4566fa34819edf81146ea336cc4c4a1a4cc
|