Install
Install Email SDK for Node.js 20+ or Bun 1.1+ with npm, pnpm, yarn or bun add, then send email from Bun or Node with ESM imports or CommonJS require.
Install the package
npm install @opencoredev/email-sdkThe public package is @opencoredev/email-sdk. The unscoped email-sdk package is unrelated.
Confirm your runtime
Use Node.js 20+ or Bun 1.1+. Every public entry point ships as both ESM and CommonJS, so import and require() work across the supported Node.js range.
const { createEmailClient } = require("@opencoredev/email-sdk");
const { resend } = require("@opencoredev/email-sdk/resend");For typed CommonJS, use module: nodenext. Use a .cts file with typed imports rather than an untyped bare require():
import sdk = require("@opencoredev/email-sdk");
import { resend } from "@opencoredev/email-sdk/resend";
const email = sdk.createEmailClient({
adapters: [resend({ apiKey: process.env.RESEND_API_KEY! })],
});Import one adapter
Adapters use separate package entry points, so your application imports only the integrations it uses.
import { createEmailClient } from "@opencoredev/email-sdk";
import { resend } from "@opencoredev/email-sdk/resend";Verify the CLI
A project install exposes the email-sdk binary. The built CLI uses a Node shebang and also runs under Bun.
npx --package @opencoredev/email-sdk email-sdk version
npx --package @opencoredev/email-sdk email-sdk adaptersFor a global Homebrew install, use brew install opencoredev/tap/email-sdk after the formula points at a published release.
Send email from Bun
Email SDK runs on Bun 1.1+ with no extra setup: install it with bun add @opencoredev/email-sdk, import an adapter, and run the file with bun. Bun loads .env files on its own, so the API key needs no dotenv import.
import { createEmailClient } from "@opencoredev/email-sdk";
import { resend } from "@opencoredev/email-sdk/resend";
const email = createEmailClient({
adapters: [resend({ apiKey: process.env.RESEND_API_KEY! })],
});
const result = await email.send({
from: "Acme <hello@acme.com>",
to: "user@example.com",
subject: "Hello from Bun",
text: "Sent with Email SDK.",
});
console.log(result.adapter, result.id);
bun run send.ts
Provider API adapters such as Resend send with fetch, which Bun provides. To check sends without delivering email, use the memory adapter with bun test; see Test email sending.
For Nodemailer over SMTP, a plain fetch call and a Bun.serve route that sends email, see How to send email from Bun.
Quickstart
Create a client and send a validated message.
Provider credentials
Set the environment variables required by your adapter.