Himalaya

CLI

命令行邮件客户端,支持 IMAP、SMTP、JMAP、Gmail 与 Microsoft Graph,多账户、可用 --json 输出,适合让 agent 查收、搜索、撰写与发送邮件;首次运行时向导会自动探测邮箱配置。

pimalaya/himalaya7.7k
README
Logo

📫 Himalaya

CLI to manage emails

Matrix Mastodon Sponsor

$ himalaya envelope search --json --sort newest-first from:alice date:2026-11-02..
{
  "envelopes": [
    {
      "id": "2",
      "messageId": "slides@example.org",
      "inReplyTo": [],
      "flags": [],
      "subject": "Slides for the review",
      "from": [{ "name": "Alice", "email": "alice@example.org" }],
      "to": [{ "name": null, "email": "me@example.org" }],
      "date": "2026-11-19T09:15:00+01:00",
      "size": 355,
      "hasAttachment": true
    },
    {
      "id": "1",
      "messageId": "lunch@example.org",
      "inReplyTo": [],
      "flags": [{ "raw": "\\Seen", "iana": "seen" }],
      "subject": "Lunch on Friday?",
      "from": [{ "name": "Alice", "email": "alice@example.org" }],
      "to": [{ "name": null, "email": "me@example.org" }],
      "date": "2026-11-18T12:30:00+01:00",
      "size": 162,
      "hasAttachment": false
    }
  ],
  "nextPage": null,
  "total": null,
  "errors": []
}

Himalaya manages your mail from the command line: every command prints JSON for scripts, frontends and agents, or plain text for a person.

Table of contents

Features

  • JSON output of every command, described by himalaya json-schema, for scripts, frontends and agents
  • Unified API for mailboxes, envelopes, flags, messages and attachments, the same on every backend
  • Protocol-specific APIs exposing the full surface of IMAP, SMTP, ManageSieve, JMAP, Gmail and Microsoft Graph
  • Local stores: Maildir, mbox and pimdir, the offline store Neverest syncs
  • One query language to search envelopes, whatever the backend
  • REPL and MCP server running commands over connections kept for the session
  • TOML configuration with several accounts, secrets read from any password manager
  • Plain text output for a person: one item per line, no border, no colour

Installation

Pre-built binary

Himalaya can be installed with the installer:

As root:

curl -sSL https://raw.githubusercontent.com/pimalaya/himalaya/master/install.sh | sudo sh

As a regular user:

curl -sSL https://raw.githubusercontent.com/pimalaya/himalaya/master/install.sh | PREFIX=~/.local sh

These commands install the latest binary from the GitHub releases section. For a build of master, check out the releases GitHub workflow and look for the Artifacts section.

Cargo
cargo install --locked --git https://github.com/pimalaya/himalaya.git
Nix
nix profile install github:pimalaya/himalaya
Sources

Requires Rust 1.89 or later:

git clone https://github.com/pimalaya/himalaya
cd himalaya
cargo build --release --locked

The binary lands at target/release/himalaya.

Configuration

Run without a configuration at a terminal, Himalaya shows the commands copying the shipped sample in place. A TOML configuration is loaded from every existing path among the following, each one deep-merged on top of the ones before:

  • $XDG_CONFIG_HOME/himalaya/config.toml
  • $HOME/.config/himalaya/config.toml
  • $HOME/.himalayarc

Override the path with -c <PATH>, repeated to merge several files. The same file backs himalaya-tui, its own keys under [tui].

[!TIP] See config.sample.toml for a complete configuration of one example account with commented fields, one section per backend; rename the account and uncomment what you need.

Proton Mail

Run Proton Bridge, which serves Proton on a local IMAP and SMTP endpoint; the password is the one the Bridge generates, not your account's.

[accounts.proton]

imap.server = "imap://127.0.0.1:1143"
imap.sasl.plain.username = "example@proton.me"
imap.sasl.plain.password.command = "pass show proton-bridge"

smtp.server = "smtp://127.0.0.1:1025"
smtp.sasl.plain.username = "example@proton.me"
smtp.sasl.plain.password.command = "pass show proton-bridge"

Fastmail

Use an app password for IMAP and SMTP, or an API token for JMAP, replacing both blocks.

[accounts.fastmail]

imap.server = "imaps://imap.fastmail.com"
imap.sasl.plain.username = "example@fastmail.com"
imap.sasl.plain.password.command = "pass show fastmail"

smtp.server = "smtps://smtp.fastmail.com"
smtp.sasl.plain.username = "example@fastmail.com"
smtp.sasl.plain.password.command = "pass show fastmail"

# jmap.server = "https://api.fastmail.com/jmap/session"
# jmap.auth.bearer.token.command = "pass show fastmail"

Gmail

Use an app password for IMAP and SMTP, or an OAuth 2.0 token from Ortie for the Gmail API, replacing both blocks. Special mailboxes live under [Gmail]/, so alias them.

[accounts.gmail]

imap.server = "imaps://imap.gmail.com:993"
imap.sasl.plain.username = "example@gmail.com"
imap.sasl.plain.password.command = "pass show gmail"

smtp.server = "smtps://smtp.gmail.com:465"
smtp.sasl.plain.username = "example@gmail.com"
smtp.sasl.plain.password.command = "pass show gmail"

mailbox.alias.sent = "[Gmail]/Sent Mail"
mailbox.alias.drafts = "[Gmail]/Drafts"
mailbox.alias.trash = "[Gmail]/Trash"
mailbox.alias.archive = "[Gmail]/All Mail"

# gmail.auth.token.command = ["ortie", "token", "show", "-a", "gmail"]

Outlook

Microsoft refuses passwords: use xoauth2 with a token from Ortie, or the Microsoft Graph API, replacing both blocks.

[accounts.outlook]

imap.server = "imaps://outlook.office365.com:993"
imap.sasl.xoauth2.username = "example@outlook.com"
imap.sasl.xoauth2.token.command = ["ortie", "token", "show", "-a", "outlook"]

smtp.server = "smtp://smtp-mail.outlook.com:587"
smtp.starttls = true
smtp.sasl.xoauth2.username = "example@outlook.com"
smtp.sasl.xoauth2.token.command = ["ortie", "token", "show", "-a", "outlook"]

# msgraph.auth.token.command = ["ortie", "token", "show", "-a", "msgraph"]

Posteo

Standard IMAP and SMTP with the account password.

[accounts.posteo]

imap.server = "imaps://posteo.de"
imap.sasl.plain.username = "example@posteo.net"
imap.sasl.plain.password.command = "pass show posteo"

smtp.server = "smtps://posteo.de"
smtp.sasl.plain.username = "example@posteo.net"
smtp.sasl.plain.password.command = "pass show posteo"

iCloud Mail

Use an app-specific password; the IMAP login is the address's name, the SMTP login the full address.

[accounts.icloud]

imap.server = "imaps://imap.mail.me.com:993"
imap.sasl.plain.username = "johnappleseed"
imap.sasl.plain.password.command = "pass show icloud"

smtp.server = "smtp://smtp.mail.me.com:587"
smtp.starttls = true
smtp.sasl.plain.username = "johnappleseed@icloud.com"
smtp.sasl.plain.password.command = "pass show icloud"

mailbox.alias.sent = "Sent Messages"

Usage

Every command runs on the default account unless -a names another, prints JSON under --json, and details its flags, exit codes and output in its --help.

himalaya account check
himalaya envelope list --json
himalaya envelope search --sort newest-first from:alice date:2d
himalaya message read 42
himalaya message reply 42 --body "Thanks!" --send
himalaya flag add --flag seen 1 2 3
himalaya imap raw 'a1 NAMESPACE'
himalaya mcp --allow-write

License

This project is licensed under either of:

Social

Sponsoring

nlnet

Special thanks to the NLnet foundation and the European Commission that have been financially supporting the project for years:

This program is part of Pimalaya, free software funded entirely by grants and donations. If you find it useful, consider sponsoring its development:

GitHub Ko-fi Buy Me a Coffee Liberapay thanks.dev PayPal