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

Production send pipeline

Combine adapters, validation, retries, fallback routes, observability, tests, and CLI checks.

What this guide builds

This guide wires Email SDK as a production transactional email send pipeline:

  1. Choose the message fields your app actually sends.
  2. Pick compatible primary and fallback adapters.
  3. Create one shared email client.
  4. Add retries and fallback routes.
  5. Add secret-safe observability.
  6. Test the send path without real providers.
  7. Verify adapter setup with the CLI.
  8. Run one live smoke send from the target environment.

Email SDK does not replace your queue, template system, campaign tool, or provider account setup. It gives your app the send layer: one message shape, explicit routing, validation, retries, fallback, hooks, plugins, tests, and CLI checks.

1. Choose the message shape

Start by listing the fields your production emails need.

If a message uses attachments, metadata, tags, reply-to, CC, BCC, or custom headers, choose adapters that can represent those fields. See Field support before adding a fallback route.

2. Pick compatible adapters

For simple text/html transactional email, Resend with SMTP fallback is a practical start.

SMTP is not a safe fallback for every message. It is best for simple address, header, text, and HTML sends.

For attachment-capable transactional email, use another API adapter as backup.

This route can send attachments through both adapters. Keep message metadata out of this route unless every configured adapter maps it.

3. Create the client

Use one client per send pipeline. Give each adapter a unique routing name when you mount more than one adapter of the same type.

Use sendMetadata in defaultsPlugin for default hook and observability context on every send. Per-send metadata in email.send(..., { metadata }) is also hook context; it merges with and overrides sendMetadata defaults for that send. Only put metadata on the EmailMessage when every route in the path supports provider message metadata.

4. Add retries and fallback

Retries happen inside the current adapter. Fallback happens after that adapter has finally failed.

Use fallbackAdapters to override the default fallback for one send.

An empty fallback list is useful when the default backup route cannot send that message shape.

5. Add safe observability

Use hooks or the observability plugin to record route behavior without leaking message content.

Safe logs usually need route name, attempt number, template or route metadata, provider status, and message ID. They usually do not need recipients, full subjects, HTML, text, API keys, SMTP passwords, or raw provider tokens.

6. Add tests with memory and capture

Use failingProvider() for the primary route and memoryProvider() for the fallback route.

Test fallback routes with the same message fields your production route uses.

7. Verify setup with the CLI

List supported adapters:

Check required configuration for one adapter:

Validate message shape and adapter field support without sending:

--dry-run does not prove deliverability. It proves that the selected adapter can represent the message shape before making a provider request.

8. Run one live smoke send

Run one live smoke send from the same environment that will send production email. Use an internal test recipient and explicit approval before sending external or user-visible email.

Provider readiness depends on verified senders or domains, API scopes, sandbox mode, recipient allow-lists, regions, rate limits, and provider policy. Email SDK can make the send path explicit; it cannot make a provider account ready.

Production checklist

  • The primary adapter and fallback adapters can represent the same required message fields.
  • Unsupported provider fields fail before silent data loss.
  • Externally visible transactional sends include idempotency keys.
  • Retry count and fallback routes are intentional for each send path.
  • Observability records route, attempt, retry, success, and error state without secrets or full message bodies.
  • Tests cover the normal route, retry behavior, and fallback route with the production message shape.
  • CLI doctor and --dry-run pass before a live smoke send.
  • One live smoke send has passed from the target environment.

Last updated on