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

mailisk

v2.1.1

Published

Mailisk library for NodeJS

Readme

Mailisk Node Client

Mailisk is an end-to-end email testing platform. It allows you to receive emails with code and automate email tests.

  • Get a unique subdomain and unlimited email addresses for free.
  • Easily automate E2E password reset and account verification by catching emails.
  • Virtual SMTP support to test outbound email without 3rd party clients.

Get started

For a more step-by-step walkthrough see the NodeJS Guide.

Installation

Install with npm

npm install --save-dev mailisk

Install with Yarn

yarn add mailisk --dev

Usage

After installing the library import it and set the API Key

const { MailiskClient } = require("mailisk");

// create client
const mailisk = new MailiskClient({ apiKey: "YOUR_API_KEY" });

// send email (using virtual SMTP)
await mailisk.sendVirtualEmail(namespace, {
  from: "[email protected]",
  to: `john@${namespace}.mailisk.net`,
  subject: "Testing",
  text: "This is a test.",
});

// receive email
const result = await mailisk.searchInbox(namespace);

console.log(result);

API Reference

This library wraps the REST API endpoints. Find out more in the API Reference.

Client functions

searchInbox(namespace, params?)

Use searchInbox to fetch messages that arrived in a given namespace, optionally waiting until the first new mail shows up.

For the full parameter options see the endpoint reference.

Default behaviour:

  • Waits until at least one new email arrives (override with wait: false).
  • Times out after 5 minutes if nothing shows up (adjust via requestOptions.timeout).
  • Ignores messages older than 15 minutes to avoid picking up leftovers from previous tests (change via from_timestamp).

Quick examples

// wait up to the default 5 min for *any* new mail
const { data: emails } = await mailisk.searchInbox(namespace);

// custom 60-second timeout
await mailisk.searchInbox(namespace, {}, { timeout: 1000 * 60 });

// polling pattern — return immediately, even if inbox is empty
await mailisk.searchInbox(namespace, { wait: false });

Filter by destination address

A common pattern is to wait for the email your UI just triggered (e.g. password-reset). Pass to_addr_prefix so you don’t pick up stale messages:

const { data: emails } = await mailisk.searchInbox(namespace, {
  to_addr_prefix: `john@${namespace}.mailisk.net`,
});

sendVirtualEmail(namespace, params)

Send an email using Virtual SMTP. This will fetch the SMTP settings for the selected namespace and send an email. These emails can only be sent to an address that ends in @{namespace}.mailisk.net.

const namespace = "mynamespace";

await mailisk.sendVirtualEmail(namespace, {
  from: "[email protected]",
  to: `john@${namespace}.mailisk.net`,
  subject: "This is a test",
  text: "Testing",
});

This does not call an API endpoint but rather uses nodemailer to send an email using SMTP.

listNamespaces()

List all namespaces associated with the current API Key.

const namespacesResponse = await mailisk.listNamespaces();

// will be ['namespace1', 'namespace2']
const namespaces = namespacesResponse.map((nr) => nr.namespace);

getAttachment(attachmentId)

Get information about an attachment.

const attachment = await mailisk.getAttachment(attachmentId);

downloadAttachment(attachmentId)

Retrieve the raw bytes of a file attached to an email message.
Typically you call this after searchInbox → iterate over email.attachments[] → pass the desired attachment.id.

Quick examples

import fs from "node:fs";
import path from "node:path";

// assume 'email' was fetched via searchInbox()
const { id, filename } = email.attachments[0];

// download the attachment
const buffer = await mailisk.downloadAttachment(id);

// save to disk (preserve original filename)
fs.writeFileSync(filename, buffer);

Streaming large files

downloadAttachment returns the entire file as a single Buffer. If you expect very large attachments and want to avoid holding them fully in memory, use getAttachment(attachmentId).download_url and stream with fetch / axios instead:

const meta = await mailisk.getAttachment(id);
const res = await fetch(meta.download_url);
const fileStream = fs.createWriteStream(filename);
await new Promise((ok, err) => res.body.pipe(fileStream).on("finish", ok).on("error", err));