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

jmap-cli

v2.4.0

Published

A command-line interface for JMAP servers.

Readme

jmap-cli

A command-line interface for interacting with a JMAP server.

jmap-cli can also be used programmatically from the browser or as a Node o package — see API.md for the full API reference.

Installation

For detailed installation and configuration instructions, please see INSTALL.md.

Quick Start

If your server supports oAuth2:

# Set your JMAP server and credentials
jmap-cli init [url of your mail server]
jmap-cli login
# List your mailboxes
jmap-cli mailboxes

Authentication

jmap-cli supports several authentication strategies

1. Basic Auth (username/password)

Set JMAP_USERNAME and JMAP_PASSWORD — the credentials are encoded as a Basic Auth header immediately. No OAuth2 involved, works with any JMAP server.

export JMAP_BASE_URL="https://mail.example.com"
export JMAP_USERNAME="[email protected]"
export JMAP_PASSWORD="s3cret!"
jmap-cli mailboxes

2. Impersonation (Stalwart admin user)

Access another user's mailbox using the Stalwart impersonation permission feature.

export JMAP_ADMIN="[email protected]"
export JMAP_PASSWORD="admin-secret"
jmap impersonate --for [email protected]

Or interactively:

jmap impersonate --for [email protected]
Impersonator email (admin account): [email protected]
Impersonator password:

After impersonation, all subsequent jmap commands run as the target user.

3. Bearer Token (pre-existing JWT)

Set JMAP_TOKEN to any access token you already have:

export JMAP_TOKEN="eyJhbGciOi..."
jmap-cli mailboxes

This tokens are short lived, you should also set the refresh token to automatically refresh the access token when it expires:

export JMAP_REFRESH_TOKEN="rt_abc123..."
jmap-cli mailboxes

4. Device Authorization Grant (interactive login)

Run jmap login for an interactive OAuth2 Device Authorization Grant (RFC 8628) flow:

jmap-cli login

This will:

  1. Contact the server's device authorization endpoint
  2. Show a URL and code to enter in your browser
  3. Wait until you complete the authorization
  4. Save the access and refresh tokens to ~/.config/jmap-cli/config

Configuration file

The config file is stored at ~/.config/jmap-cli/config and uses a simple KEY="value" format. You can edit it directly or regenerate it with jmap init.

JMAP_BASE_URL="https://mail.example.com"
JMAP_TOKEN="eyJhbGciOi..."
JMAP_REFRESH_TOKEN="rt_abc123..."

CLI Usage

jmap-cli <command> [options]

Commands

| Command | Description | |---|---| | init | Set up server URL and optionally log in via OAuth2 device flow | | login | Interactive OAuth2 Device Authorization Grant login | | impersonate | Access another user's mailbox (Stalwart master user) | | mailboxes | List mailboxes | | mailbox | Create a new mailbox | | messages | List messages in a mailbox | | message | Fetch a single message | | send | Send an email | | search | Search messages | | keyword | Set keywords (seen, answered, flagged…) on a message | | move | Move a message to a different mailbox | | listen | Listen for real-time updates (experimental) |

init

jmap-cli init [url]

Prompts for a JMAP server URL and offers to start the OAuth2 device login flow. Saves configuration to ~/.config/jmap-cli/config.

login

jmap-cli login [options]

Interactive OAuth2 Device Authorization Grant (RFC 8628) flow. Displays a URL and code — open the URL in your browser, enter the code, and the CLI saves the resulting tokens to your config file.

impersonate

jmap-cli impersonate --for <target-email> [options]

Access another user's mailbox using Stalwart's master user feature. The login string is <target>%<admin> — the admin password is used for authentication.

Options:

  • --for <email>: Target mailbox to access (required)

Environment variables:

  • JMAP_ADMIN: Admin email (prompted if not set)
  • JMAP_PASSWORD: Admin password (prompted if not set)

Examples:

# Interactive
jmap impersonate --for [email protected]

# Non-interactive
export JMAP_ADMIN="[email protected]"
export JMAP_PASSWORD="admin-secret"
jmap impersonate --for [email protected]

After running, all subsequent jmap commands operate on the target user's mailbox.

mailboxes

jmap-cli mailboxes [options]

Options:

  • -j, --json: Output as JSON

messages

jmap-cli messages [mailbox] [options]

Options:

  • -l, --limit <n>: Number of messages (default: 10)
  • --sort <prop>: Sort property (receivedAt, from, to, subject, size)
  • --order <asc|desc>: Sort order (default: desc)
  • --read[=true|false], --answered[=true|false], --starred[=true|false], --junk[=true|false], --draft[=true|false]: Filter by keyword
  • -j, --json: Output as JSON

message

jmap-cli message <message-id> [options]

Options:

  • -j, --json: Output as JSON

send

jmap-cli send <to> [options]

Options:

  • --from <email>: Sender address
  • --from-name <name>: Sender display name
  • --subject <text>: Email subject
  • --text <text>: Email body (reads from stdin if not provided)
  • --attach <file>: Attach a file

search

jmap-cli search [options] [freeform_query]

Options:

  • --from <string>, --to <string>, --subject <string>, --body <string>: Filter by field
  • --before <date>, --after <date>: Filter by date (YYYY-MM-DD)
  • -l, --limit <n>: Number of messages (default: 10)
  • --sort <prop>, --order <asc|desc>: Sort control
  • -j, --json: Output as JSON