Mailbox SDK
Put the mailbox in your own app. Send and read mail as the person signed in, from a browser, a phone or a server.
What it is
@nextmail/mailbox is the Mailbox surface of the Nextmail API, for an app a person signs in to: their mail and threads, drafts, labels, calendars, contacts, automations, tasks, rules, templates and the workspace screens around them. It is built on @nextmail/sdk, taking its transport from it, so every call, error and retry behaves the same, and it adds one rule: it acts as a person, with their access token, and never with an API key. For anything infrastructure-shaped, domains, webhooks, keys, tracking and sending, use @nextmail/sdk itself.
pnpm add @nextmail/mailboximport { createClient } from '@nextmail/mailbox' const client = createClient({ accessToken: () => fetch('/api/mail-token').then((response) => response.text()),}) await client.emails.send({ from: '[email protected]', to: '[email protected]', subject: 'Tomorrow', html: '<p>Still on for ten?</p>',})Which SDK to use
| `@nextmail/sdk` | `@nextmail/mailbox` | |
|---|---|---|
| Acts as | The workspace, with an API key | The person signed in, with an access token |
| Runs | On a server | In a browser, in a phone app or on a server |
| Reaches | Sending, domains, webhooks, keys, tracking and the rest of the infrastructure | Mail and threads, drafts, labels, calendars, contacts, automations, tasks and templates |
| Use it for | Your backend, jobs and the sending infrastructure | A mailbox inside your product |
