跳到主要内容

Himalaya

通过 IMAP/SMTP 管理电子邮件的 CLI 工具。使用 himalaya 在终端中列出、阅读、撰写、回复、转发、搜索和组织电子邮件。支持多个账户以及使用 MML(MIME 元语言)进行邮件撰写。

技能元数据

来源捆绑(默认安装)
路径skills/email/himalaya
版本1.0.0
作者community
许可证MIT
标签Email, IMAP, SMTP, CLI, Communication

参考:完整 SKILL.md

信息

以下是 Hermes 在触发此技能时加载的完整技能定义。这是技能激活时代理看到的指令。

Himalaya 电子邮件 CLI

Himalaya 是一款 CLI 电子邮件客户端,允许你使用 IMAP、SMTP、Notmuch 或 Sendmail 后端在终端中管理电子邮件。

参考资料

  • references/configuration.md(配置文件设置 + IMAP/SMTP 身份验证)
  • references/message-composition.md(用于撰写电子邮件的 MML 语法)

前提条件

  1. 已安装 Himalaya CLI(运行 himalaya --version 进行验证)
  2. ~/.config/himalaya/config.toml 处存在配置文件
  3. 已配置 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 = "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"

Hermes 集成说明

  • 阅读、列出、搜索、移动、删除均可直接通过终端工具完成
  • 撰写/回复/转发 — 为了提高可靠性,建议使用管道输入(cat << EOF | himalaya template send)。交互式 $EDITOR 模式可与 pty=true + 后台 + 进程工具配合使用,但需要知道编辑器及其命令
  • 使用 --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 john@example.com 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: you@example.com
To: sender@example.com
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: newrecipient@example.com/' | himalaya template send

撰写新电子邮件

非交互式(在 Hermes 中使用此方法) — 通过 stdin 管道传输消息:

cat << 'EOF' | himalaya template send
From: you@example.com
To: recipient@example.com
Subject: Test Message

Hello from Himalaya!
EOF

或使用 headers 标志:

himalaya message write -H "To:recipient@example.com" -H "Subject:Test" "Message body here"

注意:如果不通过管道输入,himalaya message write 会打开 $EDITOR。这可以与 pty=true + 后台模式配合使用,但管道传输更简单且更可靠。

移动/复制电子邮件

移动到文件夹:

himalaya message move 42 "Archive"

复制到文件夹:

himalaya message copy 42 "Important"

删除电子邮件

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 --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 --helphimalaya <command> --help 查看详细用法。
  • 消息 ID 相对于当前文件夹;更改文件夹后请重新列出。
  • 要撰写包含附件富文本电子邮件,请使用 MML 语法(参见 references/message-composition.md)。
  • 使用 pass、系统密钥环或输出密码的命令来安全地存储密码。