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

Create an adapter

Write your first custom provider adapter.

An adapter connects Email SDK’s normalized EmailMessage to one provider API. Start with a plain adapter. Wrap it as a plugin only when you want package-style reuse.

Adapter shape

Map the payload

Keep provider-specific mapping in a helper. That keeps the adapter easy to test.

Use the adapter directly

Wrap it as an adapter plugin

Adapter plugins are best for community packages and shared internal packages.

Consumers can now mount it with the same plugins array as other extensions:

Handle unsupported fields

Do not silently drop fields your provider cannot send. Throw a clear error instead.

This is especially important for fallback routes. A backup adapter that drops attachments, tags, or reply-to values can make a send look successful while changing the email.

Test the adapter

If your adapter accepts injected fetch, document it. It makes tests easier and keeps users from reaching for global mocks.

Checklist

  • Use one stable adapter name.
  • Return provider, id or messageId, and raw.
  • Pass context.signal into provider requests.
  • Respect context.idempotencyKey when the provider supports it.
  • Throw on unsupported fields instead of dropping them.
  • Add tests for payload mapping and provider response mapping.

See Adapter contract for the exact type reference.

Last updated on