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

Hooks

Observe sends without changing adapter code.

Hooks are for logs, metrics, tracing, and retry visibility.

Hook events

Each hook receives:

Field Notes
provider Routing name used for this attempt.
message The original EmailMessage.
attempt Current attempt number.
metadata Optional metadata passed to send.

afterSend also receives response. onRetry receives nextAttempt and delayMs. onError receives error.

Observe retries and fallback

Hooks expose the send pipeline without changing adapter code:

  • beforeSend runs for each adapter attempt.
  • onRetry shows retry scheduling for the same adapter.
  • onError shows adapter failures before fallback may continue.
  • afterSend shows the adapter that actually succeeded.

For safer default redaction, use the observability plugin.

Keep logs safe

Do not log API keys, SMTP passwords, raw tokens, full message bodies, or unnecessary recipient data. For most production logs, routing name, status, subject category, template name, and message ID are enough.

Last updated on