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

@astralibx/email-account-manager

v3.0.0

Published

Reusable email account management with Gmail + SES support, BullMQ queues, health tracking, warmup, and optional approval workflow

Readme

@astralibx/email-account-manager

A production-ready, multi-account email infrastructure library for Node.js. Manages multiple SMTP accounts (Gmail, AWS SES) with automatic health tracking, account warmup, capacity-based rotation, BullMQ job queues, draft approval workflows, IMAP bounce detection, SES webhook processing, and built-in unsubscribe handling. Plug it into any Express app with three routers and a single factory call.

Install

npm install @astralibx/email-account-manager

Peer Dependencies

| Package | Required | |---------|----------| | express | Yes | | mongoose | Yes | | ioredis | Yes | | bullmq | Yes | | nodemailer | Yes | | imapflow | Optional (IMAP bounce checking) |

npm install express mongoose ioredis bullmq nodemailer
# Optional: npm install imapflow

Quick Start

import express from 'express';
import mongoose from 'mongoose';
import Redis from 'ioredis';
import { createEmailAccountManager } from '@astralibx/email-account-manager';

const app = express();
app.use(express.json());

const db = await mongoose.createConnection('mongodb://localhost:27017/myapp');
const redis = new Redis();

const eam = createEmailAccountManager({
  db: { connection: db },
  redis: { connection: redis },
});

// Admin API (protect with your own auth middleware)
app.use('/api/email', eam.routes);

// SES webhook endpoint (public, signature-verified)
app.use('/webhooks/ses', eam.webhookRoutes.ses);

// Unsubscribe pages (public)
app.use('/unsubscribe', eam.unsubscribeRoutes);

// Send an email programmatically
const result = await eam.smtp.send({
  to: '[email protected]',
  subject: 'Hello',
  html: '<h1>Welcome!</h1>',
});

console.log(result); // { success: true, messageId: '...' }

app.listen(3000);

Features

  • Multi-account management -- Gmail and AWS SES providers with credential storage and status tracking. Details
  • Health tracking -- Automatic scoring (+1/-5/-10) with auto-disable on threshold breach. Details
  • Account warmup -- Phased volume ramp-up with configurable schedules stored per-account. Details
  • Capacity-based rotation -- Health-weighted account selection with daily limit enforcement. Details
  • Reliable sending -- BullMQ queues with retries, dev mode redirect, and per-account SMTP. Details
  • Draft approval workflow -- Create, review, approve/reject, bulk operations, send window spread. Details
  • Unsubscribe handling -- HMAC tokens, styled confirmation page, RFC 8058 one-click support. Details
  • SES webhooks -- SNS signature verification, bounce/complaint/delivery/open/click processing. Details
  • IMAP bounce detection -- Gmail IMAP polling with bounce classification. Details
  • Global settings -- Runtime-adjustable config stored in MongoDB with in-memory caching. Details
  • Error classes -- Typed errors with codes for every failure scenario. Details

Architecture

The library exposes three Express routers from a single factory call:

| Router | Purpose | Access | |--------|---------|--------| | eam.routes | Admin API -- accounts, drafts, settings, queues | Protected (add your auth middleware) | | eam.webhookRoutes.ses | SES/SNS event receiver | Public (SNS signature verified) | | eam.unsubscribeRoutes | Unsubscribe confirmation pages | Public |

All services are also available programmatically via the returned eam object. See Programmatic API.

Documentation

| Document | Description | |----------|-------------| | Configuration | Full config reference -- db, redis, ses, unsubscribe, options, hooks, logger | | Account Management | Adding accounts, providers (Gmail/SES), status lifecycle | | Health Tracking | Scoring rules, auto-disable triggers, thresholds | | Warmup System | Phases, daily limits, progression, DB-driven schedules | | Capacity Selection | Best account selection, rotation algorithm | | Email Sending | SMTP service, BullMQ queues, dev mode redirect | | Draft & Approval | Creating drafts, approval workflow, bulk operations, send window | | Unsubscribe | HMAC tokens, confirmation page, one-click, RFC 8058 | | SES Webhooks | SNS setup, signature verification, event processing | | IMAP Bounce Checking | Gmail IMAP polling, bounce classification | | Global Settings | Runtime settings, sections, caching, defaults | | API Routes | All 3 routers with endpoint tables | | Programmatic API | Using services directly via the EmailAccountManager interface | | Error Handling | All error classes with codes |

Security Notes

Credential storage: SMTP and IMAP passwords (smtp.pass, imap.pass) are stored as plaintext in MongoDB. You should encrypt these values at the application layer before passing them to this library, and decrypt them after retrieval. A built-in encryption layer is planned for a future version.

License

MIT