Skip to content

opencoredev/email-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

105 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Email SDK — Send email without provider lock-in

npm version GitHub stars Follow @leodev on X

One TypeScript client for transactional email. Pick the providers you actually send through, add retries and fallback routes, catch unsupported fields before they are silently dropped, and keep every send observable.

  • Adapters for 23 providers behind one normalized message
  • Retries within an adapter, plus fallback routes across adapters
  • Fail-fast field-support checks before a provider drops data
  • Batch personalization with per-recipient variables, plus provider-side scheduled sends
  • Observability hooks for logs, metrics, and traces
  • Test adapters that never call real providers
  • CLI for adapter discovery, doctor checks, and dry-run sends

Install

npm install @opencoredev/email-sdk

The SDK is server-side only and needs Node 20+ or Bun. Keep provider API keys out of client code.

Usage

import { createEmailClient } from "@opencoredev/email-sdk";
import { resend } from "@opencoredev/email-sdk/resend";

const email = createEmailClient({
  adapters: [resend({ apiKey: process.env.RESEND_API_KEY! })],
});

await email.send({
  from: "Acme <hello@acme.com>",
  to: "user@example.com",
  subject: "Welcome",
  html: "<p>It works.</p>",
});

Adapters

Resend, Postmark, SendGrid, AWS SES, Mailgun, Brevo, MailerSend, SparkPost, Mailchimp, Iterable, Loops, Plunk, Mailtrap, Cloudflare, Unosend, Scaleway, ZeptoMail, MailPace, Sequenzy, JetEmail, Lettermint, Primitive, SMTP, and a testing adapter, each imported from its own entry point. New here? Start with resend for the fastest first send.

CLI

npx email-sdk doctor --adapter resend

Discover adapters, validate setup, and run dry-run smoke sends from any environment.

Documentation

Full docs live at email-sdk.dev/docs. Good places to start:

Telemetry

Email SDK collects anonymous usage analytics so we can see which adapters and CLI commands get used and how often sends succeed. The first run prints a notice with opt-out instructions.

What gets collected:

  • Built-in adapter names (custom adapters are reported as custom) and CLI command names
  • Success or failure, error codes, and send duration
  • Total recipient counts (to + cc + bcc) and whether a message includes attachments (a boolean only, never the files themselves)
  • Whether a send used recipient variables or scheduling, and which delivery path ran
  • SDK version, OS, Node.js version, whether the run happens in CI (and which CI provider), and whether usage comes from the library or the bundled CLI
  • Redacted error reports: the error type, the Email SDK error code, and stack traces with file paths reduced to package-relative names. Error messages are scrubbed of email addresses, URLs, quoted text, long tokens, and home directories before upload.

Everything is tied to a random anonymous ID stored in ~/.config/email-sdk/telemetry.json. Email content, subjects, addresses, headers, attachments, API keys, and any other message data are never collected.

Opt out at any time with an environment variable:

export EMAIL_SDK_TELEMETRY=0   # or DO_NOT_TRACK=1

or per client in code:

const client = createEmailClient({ adapters: [resend({ apiKey })], telemetry: false });

Telemetry is also disabled automatically when NODE_ENV=test.

Sponsors

Email SDK is supported by companies that help keep provider integrations practical and maintained. Want your logo here? Become a sponsor →

Email SDK sponsors

Sequenzy logo
Also sponsored by Sequenzy · adapter docs

Star History

Star history

AGPL-3.0 License · Built by @leodev

About

Email SDK is a lightweight TypeScript library for sending email through Resend, Postmark, SendGrid, Mailgun, Brevo, SMTP, and more

Topics

Resources

License

Stars

332 stars

Watchers

1 watching

Forks

Sponsor this project

  •  

Packages

 
 
 

Contributors

Languages