New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

mailchan

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mailchan

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

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

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', 'your-email@gmail.com', 'your-password');

// Send an email
mail.send('recipient@example.com', '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.

Keywords

email

FAQs

Package last updated on 12 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts