OpenClaw Skills 终端邮件管理(Himalaya)技能使用参考手册
概述
Himalaya 是一个用于通过 IMAP/SMTP 协议从终端管理邮件的 CLI 工具,你可以使用它来列出、阅读、撰写、回复、转发、搜索和整理邮件,支持多账户,并且可以使用 MML(MIME 元语言)进行邮件撰写。
技能信息
名称:himalaya
描述:通过 IMAP/SMTP 协议从终端管理邮件的 CLI 工具,支持邮件列出、阅读、撰写、回复、转发、搜索和整理,支持多账户和使用 MML 语法撰写邮件。
版本:1.0.0
作者:lamelas
主页:https://github.com/pimalaya/himalaya
依赖:需要安装 himalaya CLI 工具,可以通过 brew 安装:brew install himalaya
👤 作者:lamelas
🦞 官方地址:https://clawhub.ai/lamelas/himalaya
👉 Skills 下载地址:himalaya-1.0.0.zip
前提条件
已安装 Himalaya CLI 工具,可以通过himalaya --version命令验证安装
在~/.config/himalaya/config.toml路径下有配置文件
已配置 IMAP/SMTP 凭证,密码需安全存储
配置设置
你可以运行交互式向导来设置账户:
himalaya account configure
或者手动创建~/.config/himalaya/config.toml配置文件:
[accounts.personal]
email = "you@example.com"
display-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"
常见操作
列出文件夹
himalaya folder list
列出邮件
列出收件箱中的邮件(默认):
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
回复邮件
交互式回复(打开 $EDITOR 编辑器):
himalaya message reply 42
回复所有人:
himalaya message reply 42 --all
转发邮件
himalaya message forward 42
撰写新邮件
交互式撰写(打开 $EDITOR 编辑器):
himalaya message write
使用模板直接发送:
cat << 'EOF' | himalaya template send
From: you@example.com
To: recipient@example.com
Subject: 测试邮件
这是来自Himalaya的测试邮件!
EOF
或者使用 headers 参数:
himalaya message write -H "To:recipient@example.com" -H "Subject:测试" "邮件内容"
移动 / 复制邮件
移动到指定文件夹:
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、系统密钥环或可以输出密码的命令来安全存储密码
配置参考
配置文件路径:~/.config/himalaya/config.toml
最小 IMAP + SMTP 配置
[accounts.default]
email = "user@example.com"
display-name = "你的姓名"
default = true
## 用于读取邮件的IMAP后端
backend.type = "imap"
backend.host = "imap.example.com"
backend.port = 993
backend.encryption.type = "tls"
backend.login = "user@example.com"
backend.auth.type = "password"
backend.auth.raw = "你的密码"
## 用于发送邮件的SMTP后端
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 = "user@example.com"
message.send.backend.auth.type = "password"
message.send.backend.auth.raw = "你的密码"
密码选项
明文密码(仅用于测试,不推荐)
backend.auth.raw = "你的密码"
从命令获取密码(推荐)
backend.auth.cmd = "pass show email/imap"
## backend.auth.cmd = "security find-generic-password -a user@example.com -s imap -w"
系统密钥环(需要 keyring 功能)
backend.auth.keyring = "imap-example"
然后运行himalaya account configure <account>来存储密码。
Gmail 配置
[accounts.gmail]
email = "you@gmail.com"
display-name = "你的姓名"
default = true
backend.type = "imap"
backend.host = "imap.gmail.com"
backend.port = 993
backend.encryption.type = "tls"
backend.login = "you@gmail.com"
backend.auth.type = "password"
backend.auth.cmd = "pass show google/app-password"
message.send.backend.type = "smtp"
message.send.backend.host = "smtp.gmail.com"
message.send.backend.port = 587
message.send.backend.encryption.type = "start-tls"
message.send.backend.login = "you@gmail.com"
message.send.backend.auth.type = "password"
message.send.backend.auth.cmd = "pass show google/app-password"
注意:如果 Gmail 启用了双因素认证,需要使用应用专用密码。
iCloud 配置
[accounts.icloud]
email = "you@icloud.com"
display-name = "你的姓名"
backend.type = "imap"
backend.host = "imap.mail.me.com"
backend.port = 993
backend.encryption.type = "tls"
backend.login = "you@icloud.com"
backend.auth.type = "password"
backend.auth.cmd = "pass show icloud/app-password"
message.send.backend.type = "smtp"
message.send.backend.host = "smtp.mail.me.com"
message.send.backend.port = 587
message.send.backend.encryption.type = "start-tls"
message.send.backend.login = "you@icloud.com"
message.send.backend.auth.type = "password"
message.send.backend.auth.cmd = "pass show icloud/app-password"
注意:需要在appleid.apple.com生成应用专用密码。
文件夹别名
映射自定义文件夹名称:
[accounts.default.folder.alias]
inbox = "INBOX"
sent = "Sent"
drafts = "Drafts"
trash = "Trash"
多账户配置
[accounts.personal]
email = "personal@example.com"
default = true
## ... 后端配置 ...
[accounts.work]
email = "work@company.com"
## ... 后端配置 ...
使用--account参数切换账户:
himalaya --account work envelope list
Notmuch 后端(本地邮件)
[accounts.local]
email = "user@example.com"
backend.type = "notmuch"
backend.db-path = "~/.mail/.notmuch"
OAuth2 认证(支持的提供商)
backend.auth.type = "oauth2"
backend.auth.client-id = "你的客户端ID"
backend.auth.client-secret.cmd = "pass show oauth/client-secret"
backend.auth.access-token.cmd = "pass show oauth/access-token"
backend.auth.refresh-token.cmd = "pass show oauth/refresh-token"
backend.auth.auth-url = "https://provider.com/oauth/authorize"
backend.auth.token-url = "https://provider.com/oauth/token"
其他选项
签名
[accounts.default]
signature = "此致\n你的姓名"
signature-delim = "-- \n"
下载目录
[accounts.default]
downloads-dir = "~/Downloads/himalaya"
撰写邮件的编辑器 通过环境变量设置:
export EDITOR="vim"
邮件撰写(MML 语法)
Himalaya 使用 MML(MIME 元语言)来撰写邮件,MML 是一种简单的基于 XML 的语法,可以编译成 MIME 邮件。
基本邮件结构
邮件由邮件头和邮件正文组成,两者之间用空行分隔:
From: sender@example.com
To: recipient@example.com
Subject: 你好,世界
这是邮件正文。
邮件头
常见的邮件头:
From: 发件人地址
To: 主要收件人
Cc: 抄送收件人
Bcc: 密送收件人
Subject: 邮件主题
Reply-To: 回复地址(如果与发件人地址不同)
In-Reply-To: 回复的邮件 ID
地址格式
To: user@example.com
To: 张三 <zhangsan@example.com>
To: "张三" <zhangsan@example.com>
To: user1@example.com, user2@example.com, "李四" <lisi@example.com>
纯文本邮件
简单的纯文本邮件:
From: alice@localhost
To: bob@localhost
Subject: 纯文本示例
你好,这是一封纯文本邮件。
不需要特殊格式。
此致
Alice
MML 富文本邮件
多部分邮件 替代文本 / HTML 部分:
From: alice@localhost
To: bob@localhost
Subject: 多部分示例
<#multipart type=alternative>
这是纯文本版本。
<#part type=text/html>
<html><body><h1>这是HTML版本</h1></body></html>
<#/multipart>
附件 添加附件:
From: alice@localhost
To: bob@localhost
Subject: 带附件的邮件
这是你需要的文档。
<#part filename=/path/to/document.pdf><#/part>
自定义附件名称:
<#part filename=/path/to/file.pdf name=report.pdf><#/part>
多个附件:
<#part filename=/path/to/doc1.pdf><#/part>
<#part filename=/path/to/doc2.pdf><#/part>
内嵌图片 内嵌图片:
From: alice@localhost
To: bob@localhost
Subject: 内嵌图片
<#multipart type=related>
<#part type=text/html>
<html><body>
<p>看看这张图片:</p>
<img src="cid:image1">
</body></html>
<#part disposition=inline id=image1 filename=/path/to/image.png><#/part>
<#/multipart>
混合内容(文本 + 附件)
From: alice@localhost
To: bob@localhost
Subject: 混合内容
<#multipart type=mixed>
<#part type=text/plain>
请查收附件。
此致
Alice
<#part filename=/path/to/file1.pdf><#/part>
<#part filename=/path/to/file2.zip><#/part>
<#/multipart>
MML 标签参考
<#multipart>
将多个部分组合在一起。
type=alternative: 同一内容的不同表示形式
type=mixed: 独立的部分(文本 + 附件)
type=related: 相互引用的部分(HTML + 图片)
<#part>
定义邮件的一部分。
type=<mime-type>: 内容类型(例如text/html、application/pdf)
filename=<path>: 要附加的文件路径
name=<name>: 附件的显示名称
disposition=inline: 内嵌显示,而不是作为附件
id=<cid>: 用于在 HTML 中引用的内容 ID
从 CLI 撰写邮件
交互式撰写
打开你的$EDITOR编辑器:
himalaya message write
回复邮件(打开编辑器并附带引用的邮件内容)
himalaya message reply 42
himalaya message reply 42 --all # 回复所有人
转发邮件
himalaya message forward 42
从标准输入发送
cat message.txt | himalaya template send
从 CLI 预填充邮件头
himalaya message write \
-H "To:recipient@example.com" \
-H "Subject:快速邮件" \
"邮件内容"
技巧
编辑器会打开一个模板,你需要填写邮件头和正文
保存并退出编辑器即可发送邮件;不保存直接退出则取消发送
MML 部分会在发送时编译成正确的 MIME 格式
使用himalaya message export --full查看收到邮件的原始 MIME 结构
元数据信息
该技能的元数据信息如下:
{
"ownerId": "kn71t8cr12n54xdhz51fncgg0h7yr8dt",
"slug": "himalaya",
"version": "1.0.0",
"publishedAt": 1767954271328
}

免费 AI IDE


更多建议: