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 🙏

© 2025 – Pkg Stats / Ryan Hefner

mailchan

v1.0.0

Published

Simple and flexible SMTP email sender with dry-run support for testing.

Readme

mailchan

Canonical URL:
https://alexstevovich.com/a/mailchan-nodejs

Software URL:
https://midnightcitylights.com/software/mailchan-nodejs

A simple and flexible SMTP email sender built on Nodemailer. MailChan allows for sending emails with SMTP credentials and also features dry-run mode for logging email activity without sending them.


Installation

npm install mailchan

Example

import { MailChan } from 'mailchan';

const mail = new MailChan('gmail', '[email protected]', 'your-password');

// Send an email
mail.send('[email protected]', 'Test Subject', 'This is a test email.')
    .then((response) => {
        console.log('Email sent:', response);
    })
    .catch((error) => {
        console.error('Error sending email:', error);
    });

// Enable dry-run mode (no email will be sent, but it will be logged to console)
mail.dryRun(true);

// Test SMTP connection
mail.verify()
    .then(() => console.log('SMTP connection verified successfully'))
    .catch((error) => console.error('SMTP verification failed:', error));

API

MailChan(service, user, pass, options)

Constructor
Creates an instance of the MailChan class with SMTP configuration.

Parameters:

  • service (string): The SMTP service (e.g., "gmail").
  • user (string): SMTP username (typically your email address).
  • pass (string): SMTP password or app-specific token.
  • options (object, optional):
    • dryRun (boolean, optional): If true, the emails are not sent but logged to the console (default is false).

verify(options)

Method
Verifies the SMTP connection and credentials.

Parameters:

  • options.throw (boolean, optional): If true, an error will be thrown on failure (default is false).

send(to, subject, text, fromOverride)

Method
Sends a plain-text email.

Parameters:

  • to (string | string[]): The recipient(s) of the email.
  • subject (string): The subject of the email.
  • text (string): The plain-text content of the email.
  • fromOverride (string, optional): Optional custom "from" address. If not provided, the user passed to the constructor is used.

dryRun(enable)

Method
Toggles dry-run mode.

Parameters:

  • enable (boolean): If true, emails will only be logged, not actually sent (default is true).

License

Licensed under the Apache License 2.0.