Skip to content
You're viewing documentation for v0.5.0. It may be out of date.Go to latest
Email SDK
Esc
↑↓navigate↵open⌘Jpreview
On this page

Adapter contract

Exact provider and plugin types for custom Email SDK adapters.

Custom adapters are plain objects that implement EmailProvider. They send one normalized Email SDK message through one provider.

Adapter plugins are EmailPlugin objects that register adapters. Use them when the adapter is packaged for reuse.

Contract Purpose
EmailProvider Provider implementation. Maps and sends the message.
EmailPlugin Registration wrapper. Adds adapters to a client.

Use a plain adapter directly:

Or package it as an adapter plugin. The plugin should return a stable id and one or more adapters.

For community packages, export both forms from the package root:

EmailProvider

EmailProviderContext

Field Type Notes
signal AbortSignal Optional abort signal.
idempotencyKey string Optional key from the message or send options.
attempt number Attempt number for this adapter.
metadata Record<string, unknown> Metadata passed to send.

Adapter responses

Return the provider’s raw response in raw when it helps callers debug or inspect provider-specific fields.

EmailPlugin for adapter packages

Adapter plugins should keep adapters synchronous. If the adapter needs credentials, accept them in the plugin factory and construct the adapter immediately.

Duplicate plugin IDs and duplicate adapter names throw during createEmailClient. Use one stable adapter name so routing, fallbacks, logs, and tests all refer to the same provider.

Last updated on