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

@starci/mail

v0.1.0

Published

Outgoing mail for a StarCi back end in one package: a NestJS module and a Mailer port over SMTP (nodemailer) with connect, greeting, socket and total timeouts, TLS required by default, address and message checks, coded errors, typed escaping render helper

Downloads

492

Readme

@starci/mail

Outgoing mail of a StarCi back end over SMTP: one package, two entries.

| entry | holds | |---|---| | @starci/mail | MailModule (register / registerAsync), the Mailer port under MAILER, createMailer for plain Node, the coded MailError, the typed render helpers (html, escapeHtml, renderTransactional, safeUrl) | | @starci/mail/testing | createMemoryMailer (the real checks over an in-memory outbox), mailTestingModule, testMailOptions |

The package owns nodemailer; an app imports it nowhere (the lint refuses it) and reaches the package only through integrations/mail.

MailModule.registerAsync({
    isGlobal: true,
    useFactory: () => parsedOptions, // parsed in the app (BE-CONFIG-2); the package reads no environment
})

await mailer.send({ to: "[email protected]", message: renderTransactional({
    lang: "en",
    subject: "Confirm your email",
    brand: { name: "Acme" },
    paragraphs: ["Press the button to confirm your address."],
    action: { label: "Confirm", url: confirmUrl },
}) })

What a send does

  • Checks the recipients (plain mailboxes, no display form, no line breaks, none repeated, at most maxRecipients), the sender and the message (a one-line subject, a text body, bodies under maxBodyBytes) before it connects; a failure is MAIL_ADDRESS_INVALID or MAIL_MESSAGE_INVALID.
  • Connects with connectionTimeoutMs, greetingTimeoutMs, socketTimeoutMs and bounds the whole send with sendTimeoutMs; every wait ends in MAIL_TIMEOUT.
  • Requires STARTTLS by default (security: "starttls"): a server that offers none fails the send with MAIL_TLS instead of receiving the message in the clear. "tls" is implicit TLS (port 465); "none" is a local mail sink and is refused together with a login. Certificates are verified (TLS 1.2 or later) unless allowSelfSigned is set for a development catcher.
  • Rejects with a MailError whose code is stable and whose kind is invalid, rate-limited or unavailable: MAIL_AUTH, MAIL_APP_PASSWORD, MAIL_CONNECT, MAIL_TIMEOUT, MAIL_DNS, MAIL_TLS, MAIL_SENDER, MAIL_RECIPIENT, MAIL_LIMIT, MAIL_UNKNOWN, MAIL_ADDRESS_INVALID, MAIL_MESSAGE_INVALID. The server's words ride in detail, the host and port in context, the cause in cause; the password is in none of them.

Attachments and user-chosen servers

message.attachments takes up to maxAttachments files (default 3) of maxAttachmentBytes together (default 5 MiB); attachmentContentTypes lists the admitted media types. For a server a user typed in (a workspace's own SMTP account) call assertSmtpTarget(host, port) when saving it and set publicTargetOnly on the options of the mailer you build for it: only public mail ports and only hosts that resolve to public addresses pass.

Templates are code

A template is a typed function returning { subject, text, html }. Interpolate with the html tag, which escapes every value (text, numbers, lists) and places a SafeHtml as it is; raw marks a fragment the template author wrote. renderTransactional draws the common case (heading, paragraphs, one button, a footer) with the brand name and an optional #rrggbb accent, and refuses a button link that is not an absolute web URL. The words come from the app's own copy (its i18n), never from the package.

Tests

npm test typechecks, lints and runs the node:test specs (a fake SMTP server for the transport, the checks and the render helpers over memory) under 90% line coverage. In an app's spec, register mailTestingModule(memory) and assert on memory.outbox, memory.lastTo(address) and the link of a message (the first web link of its text body).