Email SDK

Use Samva with Email SDK for provider-independent transactional email, retries, fallback routes, and typed failures.

Use @samva/email-sdk to send through Samva from Email SDK. The package exports both a Samva adapter and an adapter plugin, so you can keep Email SDK's routing, retry, fallback, and validation model while Samva delivers the message.

Samva maintains this package as an Email SDK community adapter. Keep your Samva API key in server-side code.

Install

bun add @samva/email-sdk @opencoredev/email-sdk samva

Register the adapter

email.ts
import { createEmailClient } from "@opencoredev/email-sdk";
import { samva } from "@samva/email-sdk";

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

const result = await email.send({
  from: "Samva <hello@example.com>",
  to: "ada@example.com",
  subject: "Welcome",
  html: "<p>Your workspace is ready.</p>",
  text: "Your workspace is ready.",
});

console.log(result.adapter, result.id);

The adapter preserves to, cc, bcc, replyTo, HTML, text, metadata, and in-memory attachments. It rejects headers, tags, scheduled sends, idempotency keys, and attachment paths before calling Samva instead of silently dropping unsupported fields.

Register the plugin

Use the plugin export when your application registers reusable Email SDK extensions:

email.ts
import { createEmailClient } from "@opencoredev/email-sdk";
import { samvaPlugin } from "@samva/email-sdk";

const email = createEmailClient({
  plugins: [samvaPlugin({ apiKey: process.env.SAMVA_API_KEY! })],
});

Email SDK expands personalized sends into one Samva request per recipient. API and transport failures become typed EmailAdapterError values, with ambiguous delivery classified conservatively so fallback routes do not accidentally send the same message twice.

Cookbook, example, and registry

On this page