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 語法)
前提條件
- 已安裝 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 = "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 --help或himalaya <command> --help查看詳細用法。 - 消息 ID 相對於當前文件夾;更改文件夾後請重新列出。
- 要撰寫包含附件富文本電子郵件,請使用 MML 語法(參見
references/message-composition.md)。 - 使用
pass、系統密鑰環或輸出密碼的命令來安全地存儲密碼。