Skip to main content

sendmux-mailbox

PyPI version Python versions PyPI downloads Licence

Generated Python client for the Sendmux Mailbox API.

Documentation

Requirements

  • Python 3.10 or newer.
  • A mailbox-scoped smx_mbx_* key or scoped smx_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_client
  • configure_mailbox
  • SendmuxMailboxApiClient
  • iter_mailbox_events
  • file helpers: upload_mailbox_attachment_from_file, create_mailbox_attachment_upload_from_file, upload_mailbox_attachment_via_presigned_file, and send_mailbox_message_with_files

Attachments

Message and event attachment metadata includes download_url, a short-lived presigned URL for that single attachment. Prefer download_mailbox_attachment() or read_mailbox_text_attachment() when you already have an authenticated client. Plain HTTP clients can fetch download_url promptly with no Authorization header; if it expires, 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, read_mailbox_text_attachment

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()
text = read_mailbox_text_attachment(
    client,
    message_id="msg_123",
    attachment_id=attachment.id,
)

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sendmux_mailbox-1.3.0.tar.gz (77.9 kB view details)

Uploaded Source

Built Distribution

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

sendmux_mailbox-1.3.0-py3-none-any.whl (240.2 kB view details)

Uploaded Python 3

File details

Details for the file sendmux_mailbox-1.3.0.tar.gz.

File metadata

  • Download URL: sendmux_mailbox-1.3.0.tar.gz
  • Upload date:
  • Size: 77.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for sendmux_mailbox-1.3.0.tar.gz
Algorithm Hash digest
SHA256 0cae3ca5fce8032cdc50125cd8f288d912a68b751006b6f29a5c17e5761b6d9f
MD5 cd48a66e6524b0c0b7c3e74ac6ca84be
BLAKE2b-256 81b38e553930c961e91b287e99f10cd2a84012c11f1f0cafa63284505b133168

See more details on using hashes here.

Provenance

The following attestation bundles were made for sendmux_mailbox-1.3.0.tar.gz:

Publisher: release-please.yml on Sendmux/sendmux-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sendmux_mailbox-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: sendmux_mailbox-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 240.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for sendmux_mailbox-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d4e2833d3ef530d49dc9dec537aad4e39e03f9f5245f6f58cdf86225561fe782
MD5 46c3adcef15ad861b8e656f35d97f57e
BLAKE2b-256 fc06c73b28340d2d14542879c83f394ff75e2a22156c231524f61fb8dcabb58c

See more details on using hashes here.

Provenance

The following attestation bundles were made for sendmux_mailbox-1.3.0-py3-none-any.whl:

Publisher: release-please.yml on Sendmux/sendmux-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 files

1.2.0

2 files

1.1.0

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page