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

@wisemen/nestjs-mail

v3.0.0

Published

Reusable NestJS mail infrastructure for Wisemen services.

Readme

@wisemen/nestjs-mail

Reusable NestJS mail infrastructure for Wisemen services.

What it provides

  • MailModule.forRoot() and MailModule.forRootAsync() for DI-friendly mail client wiring
  • HandlebarsRenderer integration through @wisemen/nestjs-handlebars
  • Mail providers for MailPit, Scaleway, SendGrid, and Mailgun
  • Named sender support (from as a string or { email, name? })
  • Application-defined delivery metadata
  • Delivery success and failure hooks without replacing packaged clients or queue handlers
  • Shared mail errors, enums, and message types

Usage

import { Module } from '@nestjs/common'
import { MailModule } from '@wisemen/nestjs-mail'

@Module({
  imports: [
    MailModule.forRoot({
      templateRootPath: process.cwd() + '/dist/src/modules',
      client: {
        type: 'mailpit',
        url: 'http://127.0.0.1:8025',
        defaultFrom: {
          email: '[email protected]',
          name: 'Example Team'
        }
      },
      queueName: 'mail'
    })
  ]
})
export class AppModule {}

Project-specific policy belongs outside the package. In larger apps, use forRootAsync() and resolve the client options from environment variables, feature flags, secrets, or test doubles in your own factory.

Install @wisemen/nestjs-handlebars alongside this package when you want to inject HandlebarsRenderer for template-based mail rendering.

Named senders and metadata

Both configured default senders and per-message from values accept an email string or an object with an optional display name. metadata is opaque application context exposed to delivery hooks; it is never sent to MailPit, Scaleway, or SendGrid.

await mailClient.sendMail({
  from: {
    email: '[email protected]',
    name: 'Example Tickets'
  },
  to: '[email protected]',
  subject: 'Your tickets',
  html: '<p>Your tickets are ready.</p>',
  metadata: {
    deliveryId: 'delivery-123',
    kind: 'ticket-confirmation'
  }
})

Metadata placed in SendHtmlMailJobData or SendTemplateMailJobData must be JSON-serializable because it passes through the queue.

Mailgun

MailModule.forRoot({
  client: {
    type: 'mailgun',
    domain: 'mail.example.com',
    apiKey: 'key-...',
    defaultFrom: {
      email: '[email protected]',
      name: 'Example Team'
    },
    // Use 'https://api.eu.mailgun.net' for EU-region domains. Defaults to 'https://api.mailgun.net'.
    baseUrl: 'https://api.eu.mailgun.net'
  },
  queueName: 'mail'
})

Delivery hooks

Configure one hooks object on the module. Hooks receive the configured client type, the original send options (including metadata), and either the exact SentMail[] result or the original provider error.

MailModule.forRoot({
  client: {
    type: 'mailpit',
    url: 'http://127.0.0.1:8025'
  },
  queueName: 'mail',
  deliveryHooks: {
    async onSuccess({ clientType, options, sentMails }) {
      await deliveries.markSent({
        clientType,
        metadata: options.metadata,
        providerIds: sentMails.map((mail) => mail.id)
      })
    },
    async onFailure({ clientType, options, error }) {
      await deliveries.markFailed({ clientType, metadata: options.metadata, error })
    }
  }
})

Hook failures log only the hook phase, client type, and error stack. Recipients, bodies, subjects, and metadata are never added to the log. Hook failures never turn a successful provider delivery into a failed send or replace a provider error, so they cannot trigger a duplicate-email queue retry.