Migrate from Nodemailer
Email SDK vs Nodemailer: migrate to a typed send() API, keep your SMTP setup, and add provider fallback when you need it.
If you want a Nodemailer alternative with TypeScript types and provider APIs, you don’t have to give up Nodemailer. Email SDK (@opencoredev/email-sdk) sends SMTP through Nodemailer and adds typed adapters for provider HTTP APIs, including Resend, SendGrid, Postmark, Mailgun, and Amazon SES. Your code calls one email.send() with a typed message, so moving from SMTP to a provider API, or adding a backup provider, changes the client config and not every send.
| Nodemailer | Email SDK | |
|---|---|---|
| SMTP | Yes | Yes, through Nodemailer |
| Provider HTTP APIs | Through its SES transport or third-party transports | 26 typed adapters in 3.1.0 |
| TypeScript types | Built in since v10 (@types/nodemailer before) |
Built in |
| Fallback to another provider | Write it yourself | fallback option; stops on unknown delivery by default |
| Tests without sending | Ethereal or a stream transport | memoryAdapter() |
Email SDK’s SMTP transport handles address fields, text/HTML bodies, headers, TLS upgrade, SMTP auth, RFC-safe subjects, transfer encoding, and MIME attachments.
Still choosing between SMTP and a provider’s HTTP API? How to send email from Node.js and TypeScript compares the options.
Replace the transporter
import { createEmailClient } from "@opencoredev/email-sdk";
import { smtp } from "@opencoredev/email-sdk/smtp";
const email = createEmailClient({
adapters: [
smtp({
host: process.env.SMTP_HOST!,
port: Number(process.env.SMTP_PORT ?? 587),
auth: {
user: process.env.SMTP_USER!,
pass: process.env.SMTP_PASS!,
},
}),
],
});
On a non-secure port, SMTP auth upgrades with STARTTLS by default. allowInsecureAuth exists only for trusted local test servers.
Replace sendMail
const result = await email.send(
{
from: "Acme <hello@acme.com>",
to: "user@example.com",
subject: "Welcome",
text: "Your account is ready.",
html: "<p>Your account is ready.</p>",
headers: [{ name: "X-App", value: "acme" }],
},
{ idempotencyKey: "welcome:user_123" },
);
The transport creates multipart/alternative for text plus HTML and derives Message-ID from the idempotency key.
Account for unsupported features
The SMTP adapter still has no tag, metadata, or scheduling concept. Keep a custom adapter if your SMTP workflow depends on advanced transport plugins.
Verify
SMTP_HOST=smtp.example.com npx --package @opencoredev/email-sdk email-sdk doctor --adapter smtp
npx --package @opencoredev/email-sdk email-sdk send \
--adapter smtp \
--host smtp.example.com \
--from hello@example.com \
--to user@example.com \
--subject "Migration smoke test" \
--text "Dry run only." \
--dry-run
Questions
Is Email SDK a provider’s SDK, like the resend package?
No. Email SDK is the npm package @opencoredev/email-sdk, an MIT-licensed library that isn’t tied to one provider. It sends over SMTP through Nodemailer and over the provider HTTP APIs it has adapters for, including Resend, Postmark and Amazon SES, behind one email.send() call, with optional fallback between them. The resend package is Resend’s own client for Resend’s API only. Installing @opencoredev/email-sdk also installs Nodemailer, so you don’t add it yourself.
Does Email SDK replace Nodemailer?
It wraps it for SMTP. Nodemailer is Email SDK’s only runtime dependency, and the smtp() adapter hands it the message. The provider adapters skip SMTP and call each provider’s HTTP API with fetch.
Can I fall back from SMTP to a provider API?
Yes. Register smtp() and a provider adapter on one client and list the provider under fallback.adapters. A failure the SMTP adapter can prove was not sent, such as a rejected reply code or a TLS certificate error, moves on to the backup. A connection drop or timeout counts as unknown delivery, and the default onUnknownDelivery: "stop" throws instead of risking a duplicate. See retries and fallback.
Does it run on Bun?
Yes. Email SDK runs server-side on Node.js 20+ and Bun 1.1+.
How do I test sends without an SMTP server?
Swap the adapter for memoryAdapter() from @opencoredev/email-sdk/testing, or point smtp() at a local catcher such as Mailpit. See Test email sending without sending real email.
SMTP adapter
See TLS, auth, custom names, and transport limits.