Search by

sendmux / mailbox

roshanjonah

Sendmux Mailbox API client for PHP.

v2.1.0 2026-09-11 03:30 UTC

This package is auto-updated.

Last update: 2026-09-11 03:31:59 UTC


README

Packagist version PHP version License

Sendmux Mailbox API client for PHP.

Read the PHP SDK guide at sendmux.ai/docs/sdks/php.

Requirements

  • PHP 8.2 or newer.
  • Composer.
  • A mailbox-scoped smx_mbx_ key or scoped smx_agent_ token. Alternatively, use a REST OAuth access token with the required scopes.

Installation

composer require sendmux/mailbox:^2.1

Upgrading from 1.x? Read the PHP 2.0 migration guide before changing your Composer constraint.

Usage

Create the Mailbox API client with a mailbox-scoped key or scoped agent token.

<?php

require __DIR__ . '/vendor/autoload.php';

use Sendmux\Mailbox\ClientFactory;

$mailboxApi = ClientFactory::createMailboxAPIApi(
    getenv('SENDMUX_MAILBOX_API_KEY') ?: ''
);

Use $mailboxApi->mailboxGetConnection() to test credentials without selecting a target mailbox.

The generated MailboxAPIApi exposes mailbox methods such as mailboxGetMe(), mailboxListMessages(), mailboxSendMessage(), and mailboxUploadAttachment().

Attachments and events

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 and no Authorization header. If it expires, re-fetch the message or attachment metadata to receive a fresh URL.

Use mailboxUploadAttachment() to upload bytes and pass the returned blob_id into mailboxSendMessage() attachments. Inline base64 attachments remain available in the generated send body shape for small payloads.

mailboxStreamEvents() exposes the Mailbox SSE endpoint for clients that want live message.received events.

OAuth access tokens

ClientFactory::createMailboxAPIApiWithAccessToken($accessToken) accepts a bare token or a callable returning one. Every API group factory has the same WithAccessToken variant. Providers run on each request and retry; your application owns token storage and refresh coordination. OAuth clients do not follow redirects.

$client = ClientFactory::createMailboxAPIApiWithAccessToken(
    static fn (): string => getenv('SENDMUX_ACCESS_TOKEN') ?: ''
);

See OAuth setup and lifecycle.

Features

  • Validates smx_mbx_ keys or scoped smx_agent_ tokens before configuring the client.
  • Uses https://app.sendmux.ai/api/v1 by default.
  • Adds retry and rate-limit backoff behaviour through sendmux/core.
  • Covers mailbox identity, folders, messages, attachments, submissions, threads, quota, usage, and event streams.
  • Includes generated models for Mailbox API requests and responses.

Related packages

Package Use it for
sendmux/core Shared helpers for auth, headers, retries, pagination, and errors.
sendmux/sending Sending API client.
sendmux/management Management API client.
sendmux/sdk Umbrella package that installs all PHP SDK surfaces.

Support

For help, include the package name, version, API surface, and sanitised request details. Do not include API keys, tokens, passwords, webhook secrets, customer data, or private account details.

License

MIT. See LICENSE.