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

Quickstart

Send your first transactional email, verify it from the CLI, and add a fallback route.

This page takes you from zero to a verified production-ready send path: one adapter, one send() call, a CLI check, and a fallback route.

Install the package

npm install @opencoredev/email-sdk

The SDK and CLI run server-side on Node 20+ and Bun 1.1+. See Install for CLI-only usage.

Create a client

These docs use Resend first because it has the shortest setup and broad field support. Any adapter works the same way; only the factory and credentials change.

Set RESEND_API_KEY, then:

Send an email

send resolves with a normalized response. provider tells you which adapter actually delivered, id and messageId carry the provider’s message id, and raw keeps the untouched provider payload.

The same call handles more than one-off sends: recipientVariables turns one send into a personalized batch, and sendAt schedules delivery on providers with a scheduling API.

Verify from the CLI

Check the environment, then validate a full message without sending:

--dry-run validates the message shape and the adapter’s field support and prints the message it would send. Drop the flag for one real smoke send.

Add a fallback route

A second adapter keeps simple transactional email flowing when the primary fails. SMTP is built into the SDK (no Nodemailer) and pairs well with API providers for plain text/HTML messages:

Your application code does not change. email.send(...) now tries Resend, then SMTP.

Next

Last updated on