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

@srttk/email

v1.0.1

Published

Maintainable email & templates

Readme

@srttk/email 📬

A type-safe email templating and sending solution for Node.js applications. This package helps you manage email templates and send emails with proper TypeScript support.

Features

  • 🔒 Type-safe email templates
  • 📝 Support for HTML and plain text emails
  • 🎨 Template compilation with data binding
  • ⚡ Built-in HTML to text conversion
  • 🛠️ Customizable template engine settings

Installation

npm install @srttk/email nodemailer

Quick Start

1. Define Email Templates

Create type-safe email templates with full TypeScript support:

import { IEmailTemplateRecord } from "@srttk/email";

// Define a template with typed data requirements
const welcome: IEmailTemplateRecord<{ name: string }> = {
  subject: "Welcome to Our Platform",
  body: (data) => `
    <div>
      <h1>Welcome ${data.name}!</h1>
      <p>We're excited to have you on board.</p>
    </div>
  `,
};

// Create a template collection
const templates = new EmailTemplateCollection({ welcome });

2. Set Up the Mailer

Configure your email transport settings:

import { Mailer } from "@srttk/email";

const mailer = new Mailer({
  templates: templates,
  config: {
    frommail: "[email protected]",
    fromname: "Your Company",
    host: "smtp.yourprovider.com",
    port: 587,
    username: "your-username",
    password: "your-password",
  },
});

3. Send Emails

Send emails using your templates:

// Using templates
await mailer
  .useTemplate("welcome", { name: "John Doe" })
  .send({ to: "[email protected]" });

// Or create without sending
const emailData = mailer
  .useTemplate("welcome", { name: "John Doe" })
  .create({ to: "[email protected]" });

Advanced Usage

Custom Template Files

You can use external template files:

const passwordReset: IEmailTemplateRecord<{ resetLink: string }> = {
  subject: "Password Reset Request",
  body: { path: "./templates/password-reset.html" },
};

Template Collection Options

Configure template collection settings:

const templates = new EmailTemplateCollection(
  { welcome },
  {
    templatePath: "./email-templates",
    defaultExtension: ".html",
    htmlToText: customHtmlToTextParser, // Optional custom parser
  }
);

Custom Transport

Use a custom nodemailer transport:

const customTransport = createTransport({
  // Your custom transport configuration
});

mailer.setTransport(customTransport);

Test Connection

Verify your email configuration:

const isConnected = await mailer.testConnection();
if (isConnected) {
  console.log("Email service is ready!");
}

API Reference

EmailTemplateCollection

  • constructor(templates, options?): Create a new template collection
  • compile(name, data?): Compile a template with data
  • setHtmlToText(parser): Set custom HTML to text parser

Mailer

  • constructor(settings?): Create a new mailer instance
  • setup(config): Configure SMTP settings
  • testConnection(): Test SMTP connection
  • send(options): Send an email
  • useTemplate(name, data?): Use a template for sending
  • setTransport(transport): Set custom nodemailer transport

Type Definitions

interface IEmailTemplateRecord<T = any> {
  subject: string | ((data: T) => string);
  body: string | ((data: T) => string) | { path: string };
}

interface SetupOptions {
  host: string;
  port: string | number;
  secure?: boolean;
  username: string;
  password: string;
  fromname?: string;
  frommail?: string;
}

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.