Generated Python client for the Sendmux Mailbox API.
Project description
sendmux-mailbox
Generated Python client for the Sendmux Mailbox API.
Documentation
- Mailbox API reference: sendmux.ai/docs/mailbox-api/introduction
- Source repository: Sendmux/sendmux-sdk
Requirements
- Python 3.10 or newer.
- A mailbox-scoped
smx_mbx_*key or scopedsmx_agent_*token.
Installation
pip install sendmux-mailbox
Usage
import os
from sendmux_mailbox import MailboxAPIApi, create_mailbox_client, iter_mailbox_events
client = create_mailbox_client(api_key=os.environ["SENDMUX_MAILBOX_API_KEY"])
api = MailboxAPIApi(client)
messages = api.mailbox_list_messages(limit=25)
for message in messages.data:
print(message.id, message.subject)
The package exports every generated Mailbox model and API class plus:
create_mailbox_clientconfigure_mailboxSendmuxMailboxApiClientiter_mailbox_events- file helpers:
upload_mailbox_attachment_from_file,create_mailbox_attachment_upload_from_file,upload_mailbox_attachment_via_presigned_file, andsend_mailbox_message_with_files
Attachments
Message and event attachment metadata includes download_url, a short-lived presigned URL for that single attachment. Fetch it promptly with a plain HTTP client; no Authorization header is needed. If the URL has expired, call mailbox_get_message() or list/search messages again to receive fresh metadata.
Mailbox direct uploads, presigned uploads, and file helpers share the mailbox attachment cap, currently 7,500,000 bytes per attachment. Presigned uploads also pin the exact declared byte length and content type.
import os
import urllib.request
from sendmux_mailbox import MailboxAPIApi, create_mailbox_client
client = create_mailbox_client(api_key=os.environ["SENDMUX_MAILBOX_API_KEY"])
api = MailboxAPIApi(client)
message = api.mailbox_get_message("msg_123")
attachment = message.data.attachments[0]
content = urllib.request.urlopen(attachment.download_url, timeout=30).read()
upload = api.mailbox_upload_attachment(
body=b"hello\n",
filename="hello.txt",
_headers={"Content-Type": "text/plain"},
)
api.mailbox_send_message(
send_mailbox_message_body={
"to": [{"email": "recipient@example.com", "name": None}],
"subject": "Attachment",
"text_body": "See attached.",
"attachments": [{
"blob_id": upload.data.blob_id,
"filename": "hello.txt",
"content_type": "text/plain",
}],
},
)
For local files, use helper functions so file bytes stay out of model context:
import os
from sendmux_mailbox import create_mailbox_client, send_mailbox_message_with_files
client = create_mailbox_client(api_key=os.environ["SENDMUX_MAILBOX_API_KEY"])
send_mailbox_message_with_files(
client,
files=["./report.pdf"],
idempotency_key="report-123",
body={
"to": [{"email": "recipient@example.com", "name": None}],
"subject": "Report",
"text_body": "Attached.",
},
)
Use upload_mailbox_attachment_via_presigned_file(...) when you want the upload step to use the short-lived signed URL and no API key on the file PUT. Inline base64 attachments remain available for tiny generated sends through the generated attachments[].content body shape.
Events
Use iter_mailbox_events for typed server-sent mailbox events.
for event in iter_mailbox_events(
client,
close_after=300,
event_types="message.received",
):
print(event.event_type, event.message_id)
Pagination
Use iter_cursor_pages from sendmux-core with list operations that return cursor pagination.
import os
from sendmux_core import iter_cursor_pages
from sendmux_mailbox import MailboxAPIApi, create_mailbox_client
client = create_mailbox_client(api_key=os.environ["SENDMUX_MAILBOX_API_KEY"])
api = MailboxAPIApi(client)
for message in iter_cursor_pages(lambda cursor: api.mailbox_list_messages(cursor=cursor, limit=50)):
print(message.id)
Support
Open an issue in Sendmux/sendmux-sdk with the package name, version, and request ID from any API error.
Licence
MIT. See the licence file.
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
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
File details
Details for the file sendmux_mailbox-1.1.0.tar.gz.
File metadata
- Download URL: sendmux_mailbox-1.1.0.tar.gz
- Upload date:
- Size: 77.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a35d1dbb4132def3ed06355ab648c67f3f595391746df34c28c97170f6d5ea60
|
|
| MD5 |
150c4ecc1a8c9d3559cd171860b307fc
|
|
| BLAKE2b-256 |
572fca37e0b241e4749bd78efd4d4aa72a3237262b7c6c37bec5f9236545407a
|
Provenance
The following attestation bundles were made for sendmux_mailbox-1.1.0.tar.gz:
Publisher:
release-please.yml on Sendmux/sendmux-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sendmux_mailbox-1.1.0.tar.gz -
Subject digest:
a35d1dbb4132def3ed06355ab648c67f3f595391746df34c28c97170f6d5ea60 - Sigstore transparency entry: 2057060734
- Sigstore integration time:
-
Permalink:
Sendmux/sendmux-sdk@699cc16b31b57a243694135542811e8354e62b39 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Sendmux
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-please.yml@699cc16b31b57a243694135542811e8354e62b39 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sendmux_mailbox-1.1.0-py3-none-any.whl.
File metadata
- Download URL: sendmux_mailbox-1.1.0-py3-none-any.whl
- Upload date:
- Size: 239.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54425f6dd7555795c03801c0065ac089a053d4f31b1f028870f87936a56887aa
|
|
| MD5 |
0c7273ca2b565f899580fb58f7a22060
|
|
| BLAKE2b-256 |
325314db30fdf496a89c236995dd377e12dda414383e2ed86a1f0c076c40ffae
|
Provenance
The following attestation bundles were made for sendmux_mailbox-1.1.0-py3-none-any.whl:
Publisher:
release-please.yml on Sendmux/sendmux-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sendmux_mailbox-1.1.0-py3-none-any.whl -
Subject digest:
54425f6dd7555795c03801c0065ac089a053d4f31b1f028870f87936a56887aa - Sigstore transparency entry: 2057060810
- Sigstore integration time:
-
Permalink:
Sendmux/sendmux-sdk@699cc16b31b57a243694135542811e8354e62b39 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Sendmux
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-please.yml@699cc16b31b57a243694135542811e8354e62b39 -
Trigger Event:
push
-
Statement type: