> ## Documentation Index
> Fetch the complete documentation index at: https://docs.corsair.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# SMTP2GO plugin

> Transactional email and SMS with SMTP2GO - send single, batch and MIME messages, search sent email, activity and archives, manage suppressions, sender domains, single senders, templates, webhooks, API keys, SMTP users, IP auth, allowed lists and subaccounts, read stats, and receive email and SMS webhook events.

Use **SMTP2GO** through Corsair: one client, typed API calls, and incoming webhooks.

Create an API key at app.smtp2go.com under **Sending > API keys**. Keys look like `api-` followed by 32 letters and digits, and you can give each key its own endpoint permissions and sending limit, or mark it as a sandbox key so sends do not go out. Things to know before you call:

* **Auth travels in a header.** The plugin sends `X-Smtp2go-Api-Key` on every call. It never puts the key in the request body, even though SMTP2GO's docs show body auth: error payloads can echo request fields, and a body-carried key could leak into an error report.
* **A 200 is not always full success.** `email.send` and `email.sendMime` answer HTTP 200 with `succeeded` and `failed` counts: check `failed` and the `failures` list, not just the call result. `email.sendBatch` answers one entry per message instead (an `email_id` or `schedule_id`); a message without one did not go out.
* **A message needs a body.** SMTP2GO requires at least one of `text_body`, `html_body` or `template_id`; the plugin checks this before spending a call. `subject` is optional despite the docs saying required (verified live).
* **Quota accounting.** Every To/CC/BCC recipient counts as one email against the plan. `stats.cycle` answers how many are left in the current cycle.
* **Throttling is by IP.** Too many requests OR too many error responses trip a throttle that lasts at least a minute, answered by a 429 with an empty body and no `Retry-After` header. Core waits that minute before one retry; nothing retries a 4xx, because errors feed the same throttle.
* **Regions.** Calls go to the regionless `api.smtp2go.com`, which routes to the account's region. Pass `region: 'us' | 'eu' | 'au'` to the plugin to pin a regional host.
* **Sends are never replayed.** A 5xx on a read is retried; a 5xx on a send or a removal is not, because the first attempt may have gone through.
* **Paging.** Most list operations take `continue_token` (and `page_size` or `limit`) and return the next `continue_token` in `data`; it is null on the last page. `email.searchScheduled` is the exception: it takes `page` and returns a bare list, so ask for the next `page` until a short one comes back.
* **There is no per-email status endpoint.** `/email/status/{email_id}` does not exist. Look up a sent email with `email.searchSent` filtered by `email_id`, or use `activity.search` for delivery events.
* **Webhooks.** SMTP2GO doesn't sign deliveries. Register the webhook with `auth_header_type: 'bearer'` and an `auth_header_value`, and store that value as the webhook signature: each delivery's `Authorization` header is compared with it. `webhooks.edit` replaces the whole registration, so send `url` and the auth fields again on every edit or the header is dropped (checked live 11-28). The free plan allows one webhook.
* **Plans.** On the free plan, `archive.*` answers 400 `UNKNOWN_ERROR`, the SMS reads answer 500, and subaccounts need a paid plan. `sms.send` texts real numbers and spends SMS credit.
* **Reference drift.** Checked live 11-28: `dedicated_ips/view`, `api_keys/add` and `api_keys/edit` answer an object where the reference shows an array, `ip_auth/view` and `webhook/view` answer arrays, `domain/remove` answers `data: null`, and `webhook/edit` requires `url`. The schemas follow the live answers. `api_keys/view` masks the keys, so keep the full key `apiKeys.add` returns if you need to edit or remove it.

**What you get:**

* 69 typed API operations
* 2 incoming webhook event types

## Setup

**1. Install**

```bash npm theme={null}
npm install corsair @corsair-dev/smtp2go better-sqlite3
npm install --save-dev @types/better-sqlite3
```

```bash yarn theme={null}
yarn add corsair @corsair-dev/smtp2go better-sqlite3
yarn add --dev @types/better-sqlite3
```

```bash pnpm theme={null}
pnpm install corsair @corsair-dev/smtp2go better-sqlite3
pnpm install --save-dev @types/better-sqlite3
```

```bash bun theme={null}
bun add corsair @corsair-dev/smtp2go better-sqlite3
bun add --dev @types/better-sqlite3
```

**2. Add the plugin**

```ts corsair.ts theme={null}
import Database from 'better-sqlite3';
import { createCorsair } from 'corsair';
import { smtp2go } from '@corsair-dev/smtp2go';

export const corsair = createCorsair({
	plugins: [
		smtp2go(),
	],
	database: new Database('corsair.db'),
	kek: process.env.CORSAIR_KEK!,
	multiTenancy: true,
	hub: {
		projectApiKey: process.env.CORSAIR_API_KEY!,
		signingSecret: process.env.CORSAIR_SIGNING_SECRET!,
	},
});
```

With `multiTenancy: true`, scope calls with `corsair.withTenant(id)`. See [Quick start](https://docs.corsair.dev/quick-start.md) for KEK + Hub keys, and [Multi-tenancy](https://docs.corsair.dev/concepts/multi-tenancy.md) for account isolation.

**3. Choose authentication**

> [tab] API Key (Recommended)
>
> Store the SMTP2GO API key before the first call: `pnpm corsair setup --plugin=smtp2go --tenant=acme api_key=<your-key>` (leave out `--tenant` without `multiTenancy`), or pass it as `key` in the plugin options. With Hub, each tenant enters their own key on the connect page. See [API key auth](https://docs.corsair.dev/concepts/api-key).
>
> ```ts theme={null}
> smtp2go()
> ```
>
> More: [API Key](https://docs.corsair.dev/concepts/api-key)

**4. Connect a tenant**

Mint a connect link and send the tenant to it. Hub hosts the page and delivers the result to your app — see [Connect / OAuth](https://docs.corsair.dev/management/connect).

```ts theme={null}
const { connectUrl } = await corsair.manage.connect.createLink({
	plugin: 'smtp2go',
	tenantId: 'acme',
});
// redirect the user's browser to connectUrl
```

## Example API calls

**How many emails are left in this billing cycle**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.smtp2go.api.stats.cycle({});
```

**Send a plain-text email**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.smtp2go.api.email.send({
	sender: 'John Smith <john@example.com>',
	to: ['Jane Jones <jane@example.com>'],
	subject: 'Your receipt',
	text_body: 'Thanks for your order.',
});
```

See the full list on the [API](https://docs.corsair.dev/plugins/smtp2go/api.md) page.

## Webhooks

This plugin registers **2** webhook event types. Configure the provider to POST to your Corsair HTTP handler, then use `webhookHooks` on the plugin factory.

See [Webhooks](https://docs.corsair.dev/plugins/smtp2go/webhooks.md) for every event path and payload shape, and [Webhooks concept](https://docs.corsair.dev/concepts/webhooks.md) for routing.

## What's next

> [card] [API reference](https://docs.corsair.dev/plugins/smtp2go/api.md)
>
> Every `smtp2go.api.*` operation with input and output types.

> [card] [Webhooks](https://docs.corsair.dev/plugins/smtp2go/webhooks.md)
>
> Event paths, payloads, and `webhookHooks` examples.

> [card] [Connect / OAuth](https://docs.corsair.dev/management/connect)
>
> createLink, Hub delivery, and tenant connect flows.

> [card] [Use with agents](https://docs.corsair.dev/mcp-adapters/mcp-adapters)
>
> Expose this plugin's operations as MCP tools.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.