npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bunmail/smtp

v0.0.1

Published

Direct-to-MX SMTP client for Bun. First-class TLS observability + cert-validation reporting + DKIM signing. Zero npm dependencies.

Downloads

56

Readme

@bunmail/smtp

Direct-to-MX SMTP client for Bun. First-class TLS observability + cert validation reporting + DKIM signing. Zero npm dependencies.

npm license


[!WARNING] v0.0.1 is a scaffolding release. The full API surface is declared so you can write code against it today, but sendMail() throws NotImplementedError at runtime. The SMTP state machine + DKIM signing + TLS observability land in v0.1.0. Don't ship code that calls sendMail() until then. Watch the repo for the v0.1.0 release notes.

Why

Most Bun email projects today reach for nodemailer. It works, but in direct-MX mode (no relay, send straight to the recipient's MX server) it has three sharp edges:

  1. TLS state is opaque. You don't know which cipher was negotiated, whether the peer cert validated, or even whether STARTTLS was used at all — the info response doesn't surface any of it. The only path to that data is parsing the SMTP transcript out of the logger option, which is fragile.
  2. Cert validation is all-or-nothing. rejectUnauthorized: false is the standard MTA-to-MTA practice (self-signed and expired certs are everywhere), but there's no way to track what would have happened under strict mode, and no way to enforce strict validation for known-good MX hosts (Gmail, Outlook).
  3. DKIM signing is a separate plugin. Works fine, but means another dep to keep current.

@bunmail/smtp is opinionated about all three:

  • Every sendMail returns result.tls.{used, protocol, cipher, peerCert.{subject, issuer, validFrom, validTo, selfSigned, validated}} — captured natively, no log scraping.
  • Opportunistic TLS is the default (matching real-world MTA practice). requireValidFor: ["gmail.com"] opts into strict cert validation for receivers where you know it should work.
  • DKIM signing is built-in (RFC 6376), implemented against node:crypto. No plugin, no extra dep.

Install

bun add @bunmail/smtp

Usage (v0.1.0 surface)

import { sendMail } from "@bunmail/smtp";

const result = await sendMail({
  from: "[email protected]",
  to: "[email protected]",
  subject: "Welcome",
  html: "<p>Hi!</p>",
  text: "Hi!",

  dkim: {
    domain: "your-domain.com",
    selector: "bunmail",
    privateKey: process.env.DKIM_KEY_PEM!,
  },

  tls: {
    requireValidFor: ["gmail.com"], // strict cert validation for known-good MX
  },
});

console.log("Delivered via", result.mxHost);
console.log("TLS used:", result.tls.used);
console.log("Cipher:", result.tls.cipher);
console.log("Cert validated:", result.tls.peerCert?.validated);

Result shape

{
  messageId: string;
  accepted: string[];
  rejected: string[];
  mxHost: string;
  tls: {
    used: boolean;
    protocol?: "TLSv1.2" | "TLSv1.3" | string;
    cipher?: string;
    peerCert?: {
      subject: string;
      issuer: string;
      validFrom: Date;
      validTo: Date;
      selfSigned: boolean;
      validated: boolean;
    };
  };
  trace?: string[]; // SMTP transcript when debug: true
}

Design constraints

  • Bun-only. Uses Bun.connect(), node:tls, node:dns/promises, node:crypto. Does not target Node.
  • Zero npm dependencies. Pure stdlib. No transitive supply-chain surface beyond Bun itself.
  • Direct-to-MX only (v0.1). No relay / no auth / no pooled transport. Send-to-the-recipient's-MX is the only path supported.
  • Strict TypeScript. No any, exactOptionalPropertyTypes: true, noUncheckedIndexedAccess: true.

If you need pooled transports, auth/relay mode, or Node compatibility — nodemailer is the right answer.

Roadmap

  • v0.0.1 (this release) — scaffolding. Type surface only. Throws.
  • v0.1.0 — SMTP state machine (EHLO → STARTTLS → MAIL FROM → RCPT TO → DATA → QUIT), DKIM signing, TLS metadata capture, opportunistic + strict modes. Tested against a fake-server harness.
  • v0.2.0 — auth/relay mode (PLAIN/LOGIN), connection pooling.
  • v1.0.0 — once the surface stabilises and BunMail has run on it in production for a quarter.

Used by

  • BunMail — self-hosted email API. Reference implementation; the package is extracted from BunMail's outbound transport.

License

MIT © mohamedboukari