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

@logickernel/mailotron

v0.1.4

Published

Mail automation library toolkit

Downloads

459

Readme

@logickernel/mailotron

A TypeScript library for email automation in tests. Generates unique plus-addressed inboxes and waits for emails to arrive via IMAP.

It relies on Gmail's plus-addressing: a Gmail mailbox like [email protected] also receives mail at you+<tag>@gmail.com. Gmail requires the tag to be numeric, so Mailotron generates unique numeric suffixes to give each test its own dedicated inbox.

Installation

npm install @logickernel/mailotron

Quick start

import { getInbox, waitForEmail } from '@logickernel/mailotron';

// 1. Generate a unique inbox alias
const address = getInbox();
// → '[email protected]'

// 2. Trigger something that sends an email to address …

// 3. Wait for it to arrive
try {
  const email = await waitForEmail(address, 'Welcome', { timeout: 30 });
  console.log(email.subject); // 'Welcome to Acme'
  console.log(email.text);    // plain-text body
} catch (err) {
  // Thrown when no matching email arrives within the timeout
  throw new Error(`Email not received: ${(err as Error).message}`);
}

Configuration

Copy .env.template to .env and fill in your credentials:

cp .env.template .env

Required

| Variable | Description | |---|---| | MAILOTRON_EMAIL_ADDRESS | Base Gmail address used by getInbox() | | MAILOTRON_IMAP_PASSWORD | IMAP app password |

Optional

The defaults below work out of the box with Gmail and Google Workspace. Only change these if you know what you are doing.

| Variable | Default | Description | |---|---|---| | MAILOTRON_IMAP_USER | MAILOTRON_EMAIL_ADDRESS | IMAP login username | | MAILOTRON_IMAP_HOST | imap.gmail.com | IMAP server hostname | | MAILOTRON_IMAP_PORT | 993 | IMAP server port | | MAILOTRON_IMAP_SECURE | true | Set to false to disable TLS | | MAILOTRON_SMTP_HOST | smtp.gmail.com | SMTP host (integration tests) | | MAILOTRON_SMTP_PORT | 587 | SMTP port (integration tests) | | MAILOTRON_SMTP_PASSWORD | MAILOTRON_IMAP_PASSWORD | SMTP password (integration tests) | | LOGGER_CONSOLE_FORMAT | — | Set to pretty for human-readable logs |

Gmail App Password

Gmail requires an App Password rather than your account password:

  1. Enable 2-Step Verification on your Google account.
  2. Go to Security → App passwords and generate a password for "Mail".
  3. Use that 16-character password (no spaces) as MAILOTRON_IMAP_PASSWORD.

API

getInbox(): string

Returns a unique plus-addressed inbox alias derived from MAILOTRON_EMAIL_ADDRESS, e.g. [email protected].

Throws if MAILOTRON_EMAIL_ADDRESS is not set or is not a valid email address.


waitForEmail(emailAddress, pattern, options?): Promise<Email>

Polls IMAP until an email addressed to emailAddress whose subject, text, or HTML matches pattern arrives, then resolves with a structured Email object.

| Parameter | Type | Default | Description | |---|---|---|---| | emailAddress | string | — | Recipient address to match (plus-tag or base) | | pattern | string \| RegExp | — | Tested against subject, text body, and HTML | | options.timeout | number | 10 | Seconds before rejecting with a Timeout error | | options.since | Date \| number | 10 min ago | Only consider emails received after this point |

interface Email {
  subject: string;
  text: string;
  html: string;
  messageId: string;
  from: string;
  to: string[];
  cc: string[];
  bcc: string[];
  replyTo: string;
  /** ISO 8601 string, or null if the message had no Date header */
  date: string | null;
  priority: string;
  attachments: EmailAttachment[];
}

interface EmailAttachment {
  filename: string;
  contentType: string;
  size: number;
}

Rejects with Error('Timeout: …') if no matching email arrives within the timeout.

Development

npm run build          # compile TypeScript → dist/
npm run typecheck      # type-check without emitting
npm test               # unit tests (Jest + ts-jest, no network required)
npm run test:integration  # end-to-end test (requires .env with SMTP + IMAP credentials)