himalaya

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Himalaya Email CLI

Himalaya Email CLI

Himalaya is a CLI email client that lets you manage emails from the terminal using IMAP, SMTP, Notmuch, or Sendmail backends.
This skill is separate from the Hermes Email gateway adapter. The gateway adapter lets people email the agent and uses Hermes' built-in IMAP/SMTP adapter; this skill lets the agent operate a mailbox from terminal tools and requires the external
himalaya
CLI.
Himalaya 是一款CLI邮件客户端,可让你通过终端使用IMAP、SMTP、Notmuch或Sendmail后端管理邮件。
本技能独立于Hermes邮件网关适配器。网关适配器支持用户向Agent发送邮件,并使用Hermes内置的IMAP/SMTP适配器;而本技能则让Agent通过终端工具操作邮箱,需要外部的
himalaya
CLI工具。

References

参考资料

  • references/configuration.md
    (config file setup + IMAP/SMTP authentication)
  • references/message-composition.md
    (MML syntax for composing emails)
  • references/configuration.md
    (配置文件设置 + IMAP/SMTP认证)
  • references/message-composition.md
    (用于撰写邮件的MML语法)

Prerequisites

前置条件

  1. Himalaya CLI installed (
    himalaya --version
    to verify)
  2. A configuration file at
    ~/.config/himalaya/config.toml
  3. IMAP/SMTP credentials configured (password stored securely)
  1. 已安装Himalaya CLI(可通过
    himalaya --version
    验证)
  2. ~/.config/himalaya/config.toml
    路径下存在配置文件
  3. 已配置IMAP/SMTP凭据(密码需安全存储)

Installation

安装方式

bash
undefined
bash
undefined

Pre-built binary (Linux/macOS — recommended)

预编译二进制包(Linux/macOS — 推荐)

macOS via Homebrew

macOS 可通过Homebrew安装

brew install himalaya
brew install himalaya

Or via cargo (any platform with Rust)

或通过cargo安装(任何支持Rust的平台)

cargo install himalaya --locked
undefined
cargo install himalaya --locked
undefined

Configuration Setup

配置设置

Run the interactive wizard to set up an account:
bash
himalaya account configure
Or create
~/.config/himalaya/config.toml
manually:
toml
[accounts.personal]
email = "you@example.com"
display-name = "Your Name"
default = true

backend.type = "imap"
backend.host = "imap.example.com"
backend.port = 993
backend.encryption.type = "tls"
backend.login = "you@example.com"
backend.auth.type = "password"
backend.auth.cmd = "pass show email/imap"  # or use keyring

message.send.backend.type = "smtp"
message.send.backend.host = "smtp.example.com"
message.send.backend.port = 587
message.send.backend.encryption.type = "start-tls"
message.send.backend.login = "you@example.com"
message.send.backend.auth.type = "password"
message.send.backend.auth.cmd = "pass show email/smtp"
运行交互式向导来设置账户:
bash
himalaya account configure
或手动创建
~/.config/himalaya/config.toml
文件:
toml
[accounts.personal]
email = "you@example.com"
display-name = "Your Name"
default = true

backend.type = "imap"
backend.host = "imap.example.com"
backend.port = 993
backend.encryption.type = "tls"
backend.login = "you@example.com"
backend.auth.type = "password"
backend.auth.cmd = "pass show email/imap"  # 或使用密钥环

message.send.backend.type = "smtp"
message.send.backend.host = "smtp.example.com"
message.send.backend.port = 587
message.send.backend.encryption.type = "start-tls"
message.send.backend.login = "you@example.com"
message.send.backend.auth.type = "password"
message.send.backend.auth.cmd = "pass show email/smtp"

Folder aliases (himalaya v1.2.0+ syntax). Required whenever the

文件夹别名(himalaya v1.2.0+ 语法)。当服务器的文件夹名称与himalaya的标准名称(inbox/sent/drafts/trash)不匹配时,必须设置别名

server's folder names don't match himalaya's canonical names

Gmail是常见情况 — 查看
references/configuration.md
了解
[Gmail]/Sent Mail
的映射方式。

(inbox/sent/drafts/trash). Gmail is the common case — see

references/configuration.md
for the
[Gmail]/Sent Mail
mapping.

folder.aliases.inbox = "INBOX" folder.aliases.sent = "Sent" folder.aliases.drafts = "Drafts" folder.aliases.trash = "Trash"

> **Heads up on the alias syntax.** Pre-v1.2.0 docs used a
> `[accounts.NAME.folder.alias]` sub-section (singular `alias`).
> v1.2.0 silently ignores that form — TOML parses fine, but the
> alias resolver never reads it, so every lookup falls through to
> the canonical name. On Gmail this means save-to-Sent fails *after*
> SMTP delivery succeeds, and `himalaya message send` exits non-zero.
> Any caller (agent, script, user) that retries on that exit code
> will re-run the entire send — including SMTP — producing duplicate
> emails to recipients. Always use `folder.aliases.X` (plural, dotted
> keys, directly under `[accounts.NAME]`).
folder.aliases.inbox = "INBOX" folder.aliases.sent = "Sent" folder.aliases.drafts = "Drafts" folder.aliases.trash = "Trash"

> **别名语法注意事项**。v1.2.0之前的文档使用`[accounts.NAME.folder.alias]`子节(单数`alias`)。
> v1.2.0会静默忽略该格式 — TOML解析正常,但别名解析器不会读取它,因此所有查找都会使用标准名称。在Gmail上,这意味着SMTP投递成功后,保存到已发送文件夹会失败,且`himalaya message send`会返回非零退出码。
> 任何调用者(Agent、脚本、用户)如果根据该退出码重试,会重新执行整个发送流程 — 包括SMTP — 导致收件人收到重复邮件。请务必使用`folder.aliases.X`(复数,点式键,直接位于`[accounts.NAME]`下)。

Hermes Integration Notes

Hermes集成说明

  • Reading, listing, searching, moving, deleting all work directly through the terminal tool
  • Composing/replying/forwarding — piped input (
    cat << EOF | himalaya template send
    ) is recommended for reliability. Interactive
    $EDITOR
    mode works with
    pty=true
    + background + process tool, but requires knowing the editor and its commands
  • Use
    --output json
    for structured output that's easier to parse programmatically
  • The
    himalaya account configure
    wizard requires interactive input — use PTY mode:
    terminal(command="himalaya account configure", pty=true)
  • 读取、列出、搜索、移动、删除操作均可直接通过终端工具完成
  • 撰写/回复/转发 — 推荐使用管道输入(
    cat << EOF | himalaya template send
    )以保证可靠性。交互式
    $EDITOR
    模式可配合
    pty=true
    + 后台 + 进程工具使用,但需要了解编辑器及其命令
  • 使用
    --output json
    获取结构化输出,便于程序化解析
  • himalaya account configure
    向导需要交互式输入 — 使用PTY模式:
    terminal(command="himalaya account configure", pty=true)

Common Operations

常见操作

List Folders

列出文件夹

bash
himalaya folder list
bash
himalaya folder list

List Emails

列出邮件

List emails in INBOX (default):
bash
himalaya envelope list
List emails in a specific folder:
bash
himalaya envelope list --folder "Sent"
List with pagination:
bash
himalaya envelope list --page 1 --page-size 20
列出收件箱中的邮件(默认):
bash
himalaya envelope list
列出特定文件夹中的邮件:
bash
himalaya envelope list --folder "Sent"
分页列出邮件:
bash
himalaya envelope list --page 1 --page-size 20

Search Emails

搜索邮件

bash
himalaya envelope list from john@example.com subject meeting
bash
himalaya envelope list from john@example.com subject meeting

Read an Email

读取邮件

Read email by ID (shows plain text):
bash
himalaya message read 42
Export raw MIME:
bash
himalaya message export 42 --full
通过ID读取邮件(显示纯文本):
bash
himalaya message read 42
导出原始MIME格式:
bash
himalaya message export 42 --full

Reply to an Email

回复邮件

To reply non-interactively from Hermes, read the original message, compose a reply, and pipe it:
bash
undefined
要从Hermes非交互式回复邮件,需先读取原始邮件,撰写回复内容后通过管道发送:
bash
undefined

Get the reply template, edit it, and send

获取回复模板,编辑后发送

himalaya template reply 42 | sed 's/^$/\nYour reply text here\n/' | himalaya template send

Or build the reply manually:

```bash
cat << 'EOF' | himalaya template send
From: you@example.com
To: sender@example.com
Subject: Re: Original Subject
In-Reply-To: <original-message-id>

Your reply here.
EOF
Reply-all (interactive — needs $EDITOR, use template approach above instead):
bash
himalaya message reply 42 --all
himalaya template reply 42 | sed 's/^$/\n你的回复内容\n/' | himalaya template send

或手动构建回复:

```bash
cat << 'EOF' | himalaya template send
From: you@example.com
To: sender@example.com
Subject: Re: Original Subject
In-Reply-To: <original-message-id>

你的回复内容。
EOF
回复所有人(交互式 — 需要$EDITOR,建议使用上述模板方式):
bash
himalaya message reply 42 --all

Forward an Email

转发邮件

bash
undefined
bash
undefined

Get forward template and pipe with modifications

获取转发模板并修改后通过管道发送

himalaya template forward 42 | sed 's/^To:.*/To: newrecipient@example.com/' | himalaya template send
undefined
himalaya template forward 42 | sed 's/^To:.*/To: newrecipient@example.com/' | himalaya template send
undefined

Write a New Email

撰写新邮件

Non-interactive (use this from Hermes) — pipe the message via stdin:
bash
cat << 'EOF' | himalaya template send
From: you@example.com
To: recipient@example.com
Subject: Test Message

Hello from Himalaya!
EOF
Or with headers flag:
bash
himalaya message write -H "To:recipient@example.com" -H "Subject:Test" "Message body here"
Note:
himalaya message write
without piped input opens
$EDITOR
. This works with
pty=true
+ background mode, but piping is simpler and more reliable.
非交互式(推荐在Hermes中使用) — 通过标准输入管道传递邮件内容:
bash
cat << 'EOF' | himalaya template send
From: you@example.com
To: recipient@example.com
Subject: Test Message

来自Himalaya的问候!
EOF
或使用头部参数:
bash
himalaya message write -H "To:recipient@example.com" -H "Subject:Test" "邮件正文内容"
注意:不带管道输入的
himalaya message write
会打开
$EDITOR
。该方式可配合
pty=true
+ 后台模式使用,但管道方式更简单可靠。

Move/Copy Emails

移动/复制邮件

Move to folder:
bash
himalaya message move 42 "Archive"
Copy to folder:
bash
himalaya message copy 42 "Important"
移动到指定文件夹:
bash
himalaya message move 42 "Archive"
复制到指定文件夹:
bash
himalaya message copy 42 "Important"

Delete an Email

删除邮件

bash
himalaya message delete 42
bash
himalaya message delete 42

Manage Flags

管理标记

Add flag:
bash
himalaya flag add 42 --flag seen
Remove flag:
bash
himalaya flag remove 42 --flag seen
添加标记:
bash
himalaya flag add 42 --flag seen
移除标记:
bash
himalaya flag remove 42 --flag seen

Multiple Accounts

多账户管理

List accounts:
bash
himalaya account list
Use a specific account:
bash
himalaya --account work envelope list
列出账户:
bash
himalaya account list
使用指定账户:
bash
himalaya --account work envelope list

Attachments

附件管理

Save attachments from a message:
bash
himalaya attachment download 42
Save to specific directory:
bash
himalaya attachment download 42 --dir ~/Downloads
保存邮件中的附件:
bash
himalaya attachment download 42
保存到指定目录:
bash
himalaya attachment download 42 --dir ~/Downloads

Output Formats

输出格式

Most commands support
--output
for structured output:
bash
himalaya envelope list --output json
himalaya envelope list --output plain
大多数命令支持
--output
参数以获取结构化输出:
bash
himalaya envelope list --output json
himalaya envelope list --output plain

Debugging

调试

Enable debug logging:
bash
RUST_LOG=debug himalaya envelope list
Full trace with backtrace:
bash
RUST_LOG=trace RUST_BACKTRACE=1 himalaya envelope list
启用调试日志:
bash
RUST_LOG=debug himalaya envelope list
带回溯的完整跟踪:
bash
RUST_LOG=trace RUST_BACKTRACE=1 himalaya envelope list

Tips

小贴士

  • Use
    himalaya --help
    or
    himalaya <command> --help
    for detailed usage.
  • Message IDs are relative to the current folder; re-list after folder changes.
  • For composing rich emails with attachments, use MML syntax (see
    references/message-composition.md
    ).
  • Store passwords securely using
    pass
    , system keyring, or a command that outputs the password.
  • 使用
    himalaya --help
    himalaya <command> --help
    查看详细用法。
  • 邮件ID是相对于当前文件夹的;切换文件夹后需重新列出邮件。
  • 如需撰写带附件的富文本邮件,请使用MML语法(查看
    references/message-composition.md
    )。
  • 使用
    pass
    、系统密钥环或可输出密码的命令来安全存储密码。