关于 himalaya
himalaya 是面向 Agent 和脚本的终端邮件客户端技能,通过外部 Himalaya CLI 使用 IMAP、SMTP、Notmuch 或 Sendmail 管理邮件。
主要功能
- 01列出、搜索和阅读邮件
- 02撰写、回复和转发邮件
- 03移动、复制、删除邮件及管理标记
- 04管理多个账户和文件夹
- 05下载附件并导出结构化输出
适用场景
- 01按发件人或主题搜索邮箱
- 02通过终端工具起草并发送回复
- 03归档或删除邮件并更新标记
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ nousresearch/ hermes-agent --skill himalaya安装后在 Claude Code 中输入/himalaya确认已加载。
附带文件references/configuration.mdreferences/message-composition.md
详细介绍
Himalaya 邮件命令行
Himalaya 是一款命令行邮件客户端,可通过 IMAP、SMTP、Notmuch 或 Sendmail 后端在终端中管理邮件。
此技能与 Hermes 邮件网关适配器相互独立。网关
适配器允许用户向 Agent 发送邮件,并使用 Hermes 内置的 IMAP/SMTP
适配器;此技能则允许 Agent 通过终端工具操作邮箱,
并且需要外部的 himalaya CLI。
参考资料
references/configuration.md(配置文件设置 + IMAP/SMTP 身份验证)references/message-composition.md(撰写邮件时使用的 MML 语法)
先决条件
- 已安装 Himalaya CLI(运行
himalaya --version验证) - 配置文件位于
~/.config/himalaya/config.toml - 已配置 IMAP/SMTP 凭据(密码需安全存储)
安装
# Pre-built binary (Linux/macOS — recommended)
curl -sSL https://raw.githubusercontent.com/pimalaya/himalaya/master/install.sh | PREFIX=~/.local sh
# macOS via Homebrew
brew install himalaya
# Or via cargo (any platform with Rust)
cargo install himalaya --locked
配置设置
运行交互式向导来设置帐户:
himalaya account configure
或者手动创建 ~/.config/himalaya/config.toml:
[accounts.personal]
email = "[email protected]"
display-name = "Your Name"
default = true
backend.type = "imap"
backend.host = "imap.example.com"
backend.port = 993
backend.encryption.type = "tls"
backend.login = "[email protected]"
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 = "[email protected]"
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
# server's folder names don't match himalaya's canonical names
# (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"
别名语法提示。 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 集成说明
- 读取、列出、搜索、移动、删除均可直接通过终端工具完成
- 撰写/回复/转发——为确保可靠性,建议使用管道输入(
cat << EOF | himalaya template send)。交互式$EDITOR模式可配合pty=true+ 后台模式 + process 工具使用,但需要了解所用编辑器及其命令 - 使用
--output json获取更易于以编程方式解析的结构化输出 himalaya account configure向导需要交互式输入——请使用 PTY 模式:terminal(command="himalaya account configure", pty=true)
常见操作
列出文件夹
himalaya folder list
列出邮件
列出 INBOX 中的邮件(默认):
himalaya envelope list
列出指定文件夹中的邮件:
himalaya envelope list --folder "Sent"
分页列出:
himalaya envelope list --page 1 --page-size 20
搜索邮件
himalaya envelope list from [email protected] subject meeting
阅读邮件
按 ID 阅读邮件(显示纯文本):
himalaya message read 42
导出原始 MIME:
himalaya message export 42 --full
回复邮件
若要在 Hermes 中以非交互方式回复,请先阅读原始邮件,撰写回复,然后通过管道传入:
# Get the reply template, edit it, and send
himalaya template reply 42 | sed 's/^$/\nYour reply text here\n/' | himalaya template send
或者手动撰写回复:
cat << 'EOF' | himalaya template send
From: [email protected]
To: [email protected]
Subject: Re: Original Subject
In-Reply-To: <original-message-id>
Your reply here.
EOF
回复所有人(交互式——需要 $EDITOR,建议改用上面的模板方式):
himalaya message reply 42 --all
转发邮件
# Get forward template and pipe with modifications
himalaya template forward 42 | sed 's/^To:.*/To: [email protected]/' | himalaya template send
撰写新邮件
非交互式(在 Hermes 中使用此方式)——通过 stdin 管道传入邮件内容:
cat << 'EOF' | himalaya template send
From: [email protected]
To: [email protected]
Subject: Test Message
Hello from Himalaya!
EOF
或者使用 headers 标志:
himalaya message write -H "To:[email protected]" -H "Subject:Test" "Message body here"
注意:不通过管道输入运行 himalaya message write 会打开 $EDITOR。此方式可配合 pty=true + 后台模式使用,但通过管道输入更简单可靠。
移动/复制邮件
移动到文件夹(先指定目标文件夹,再指定邮件 ID):
himalaya message move "Archive" 42
复制到文件夹(先指定目标文件夹,再指定邮件 ID):
himalaya message copy "Important" 42
删除邮件
himalaya message delete 42
管理标志
添加标志:
himalaya flag add 42 --flag seen
移除标志:
himalaya flag remove 42 --flag seen
多个帐户
列出帐户:
himalaya account list
使用指定帐户:
himalaya --account work envelope list
附件
保存邮件中的附件:
himalaya attachment download 42
保存到指定目录:
himalaya attachment download 42 --downloads-dir ~/Downloads
输出格式
大多数命令都支持 --output,可生成结构化输出:
himalaya envelope list --output json
himalaya envelope list --output plain
调试
启用调试日志:
RUST_LOG=debug himalaya envelope list
启用完整回溯:
RUST_LOG=trace RUST_BACKTRACE=1 himalaya envelope list
提示
- 使用
himalaya --help或himalaya <command> --help查看详细用法。 - 邮件 ID 是相对于当前文件夹的;切换文件夹后请重新列出。
- 若要撰写带附件的富文本邮件,请使用 MML 语法(参见
references/message-composition.md)。 - 使用
pass、系统密钥环或可输出密码的命令安全地存储密码。