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

@lara-node/mail

v0.1.8

Published

Lara-Node mail manager with SMTP, log, and array drivers

Downloads

1,183

Readme

@lara-node/mail

Multi-driver mailer (SMTP, log, array, failover) with a Mailable base class, queued mail, and full TypeScript types.

Installation

pnpm add @lara-node/mail

Quick Start

import { Mail } from '@lara-node/mail';
import { WelcomeMail } from './app/Mail/WelcomeMail';

// Send immediately
await Mail.to('[email protected]').send(new WelcomeMail(user));

// Queue for background delivery
await Mail.to('[email protected]').queue(new WelcomeMail(user));

// Schedule for later
await Mail.to('[email protected]').later(new WelcomeMail(user), 300); // 5 min delay

Creating a Mailable

Extend the Mailable base class and implement build():

import { Mailable } from '@lara-node/mail';

interface User {
  name: string;
  email: string;
}

export class WelcomeMail extends Mailable {
  constructor(private readonly user: User) {
    super();
  }

  build(): this {
    return this
      .subject(`Welcome, ${this.user.name}!`)
      .from('[email protected]', 'My App')
      .html(`<h1>Hello ${this.user.name}</h1><p>Thanks for signing up.</p>`)
      .text(`Hello ${this.user.name}. Thanks for signing up.`);
  }
}

Mailable fluent methods

All methods return this for chaining and must be called inside build().

this.subject('Your order has shipped')
this.from('[email protected]')
this.from('[email protected]', 'My App')
this.html('<p>Hello</p>')
this.text('Hello')
this.attach('/path/to/invoice.pdf')
this.attach('/path/to/file.csv', { filename: 'report.csv', contentType: 'text/csv' })
this.cc('[email protected]')
this.bcc('[email protected]')
this.replyTo('[email protected]')
this.priority('high')          // 'high' | 'normal' | 'low'
this.tag('transactional')      // tag for analytics / filtering
this.mailer('smtp')            // override the default mailer for this message
this.with({ code: '123456' })  // pass data to the template (if using a view engine)

Mail Facade

Mail.to(address)

Returns a PendingMail builder.

Mail.to('[email protected]')
Mail.to(['[email protected]', '[email protected]'])
Mail.to({ address: '[email protected]', name: 'Alice' })

PendingMail methods

await pending.send(mailable)              // send synchronously
await pending.queue(mailable)             // dispatch to queue
await pending.later(mailable, delaySeconds) // dispatch after a delay

Sending to multiple recipients

const users = await User.all();

for (const user of users) {
  await Mail.to(user.email).queue(new NewsletterMail(user));
}

Multiple Mailers

Configure multiple mailers in config/mail.ts:

import { setConfig } from '@lara-node/core';

setConfig('mail', {
  default: 'smtp',
  mailers: {
    smtp: {
      transport: 'smtp',
      host: process.env.MAIL_HOST,
      port: Number(process.env.MAIL_PORT ?? 587),
      username: process.env.MAIL_USERNAME,
      password: process.env.MAIL_PASSWORD,
      encryption: process.env.MAIL_ENCRYPTION ?? 'tls',
    },
    log: {
      transport: 'log',
    },
    failover: {
      transport: 'failover',
      mailers: ['smtp', 'log'],
    },
  },
  from: {
    address: process.env.MAIL_FROM_ADDRESS ?? '[email protected]',
    name: process.env.MAIL_FROM_NAME ?? 'My App',
  },
});

Override the mailer for a single message:

this.mailer('log');  // inside build()

MailServiceProvider

import { MailServiceProvider } from '@lara-node/mail';

app.register(MailServiceProvider);

Environment Variables

| Variable | Default | Description | |------------------------|------------|------------------------------------------------------------| | MAIL_MAILER | smtp | Default mailer name | | MAIL_HOST | — | SMTP host | | MAIL_PORT | 1025 | SMTP port | | MAIL_USERNAME | — | SMTP username | | MAIL_PASSWORD | — | SMTP password | | MAIL_ENCRYPTION | — | tls, ssl, or empty | | MAIL_FROM_ADDRESS | — | Default sender address | | MAIL_FROM_NAME | — | Default sender display name | | MAIL_FAILOVER_MAILERS| — | Comma-separated mailers for the failover driver |

Notes

  • The log driver writes mail content to the application log rather than sending — useful during development.
  • The array driver stores sent messages in memory and exposes them for inspection in tests.
  • Queued mail requires a configured queue connection. See @lara-node/queue.
  • attach() resolves paths relative to process.cwd().