English | 中文
一个命令行工具,用于统一管理多个邮箱账户(Gmail、Outlook、网易邮箱 163/126)。
# 安装
clawhub install one-mail
# 初始化配置
bash scripts/setup.sh# 克隆仓库
git clone https://github.com/huangbaixun/one-mail.git
cd one-mail
# 初始化配置
bash scripts/setup.shbash scripts/setup.sh按照提示添加你的邮箱账户。
# 收取所有账户的邮件
bash scripts/fetch.sh
# 只看未读邮件
bash scripts/fetch.sh --unread
# 搜索邮件
bash scripts/fetch.sh --query "AI agent"
# 指定账户
bash scripts/fetch.sh --account gmail# 使用默认账户发送
bash scripts/send.sh \
--to "recipient@example.com" \
--subject "Hello" \
--body "Email content"
# 带附件
bash scripts/send.sh \
--to "recipient@example.com" \
--subject "Report" \
--body "See attachment" \
--attach "/path/to/file.pdf"- ✅ 收取邮件
- ✅ 发送邮件
- ✅ 附件支持
- ✅ 搜索过滤
- 依赖:
gogCLI(已配置)
- ✅ 收取邮件
- ✅ 发送邮件
- ✅ 附件支持(< 3MB)
- ✅ 搜索过滤
- 依赖:Microsoft Graph API
- ✅ 收取邮件
- ✅ 发送邮件
- ✅ 附件支持
- ✅ 搜索过滤
- ✅ IMAP ID 支持(自动发送客户端标识)
- 依赖:Python 3 + imaplib
- 163 服务器:imap.163.com / smtp.163.com
- 126 服务器:imap.126.com / smtp.126.com
配置文件位于 ~/.onemail/:
config.json- 账户配置credentials.json- 敏感凭证(600 权限)
# 列出所有账户
bash scripts/accounts.sh list
# 添加新账户
bash scripts/accounts.sh add
# 删除账户
bash scripts/accounts.sh remove --name outlook
# 设置默认账户
bash scripts/accounts.sh set-default --name gmail
# 测试账户连接
bash scripts/accounts.sh test --name gmail添加到 crontab:
# 每小时检查一次未读邮件
0 * * * * cd ~/clawd/skills/one-mail && bash scripts/fetch.sh --unread | jq -r '.[] | "\(.from): \(.subject)"'# 回复最新的紧急邮件
cd ~/clawd/skills/one-mail
bash scripts/fetch.sh --query "urgent" --limit 1 | \
jq -r '.[0].id' | \
xargs -I {} bash scripts/send.sh \
--reply-to {} \
--body "I'll get back to you soon"# 搜索所有账户中包含 "invoice" 的邮件
cd ~/clawd/skills/one-mail
bash scripts/fetch.sh --query "invoice" | \
jq -r '.[] | "\(.account) - \(.from): \(.subject)"'所有邮件以 JSON 格式输出:
[
{
"id": "msg_123",
"account": "gmail",
"from": "sender@example.com",
"to": "you@gmail.com",
"subject": "Meeting tomorrow",
"date": "2026-03-07T10:30:00Z",
"unread": true,
"has_attachments": false,
"snippet": "Let's meet at 3pm..."
}
]可以使用 jq 进行过滤和格式化。
- 所有凭证存储在
~/.onemail/credentials.json(600 权限) - 支持 macOS Keychain 存储(可选)
- OAuth 2.0 认证(Gmail、Outlook)
- 应用专用密码(网易邮箱)
确保 gog CLI 已正确配置:
gog gmail list --limit 1- 检查 Client ID 和 Client Secret
- 确保重定向 URI 设置为
http://localhost - 确保授权范围包含
Mail.ReadWrite和Mail.Send
- 确保已开启 IMAP/SMTP 服务
- 使用应用专用密码,不是登录密码
- 检查防火墙是否阻止 993/465 端口
- IMAP ID 问题:one-mail 已自动发送 IMAP ID 命令,符合网易邮箱要求
- 163 使用 imap.163.com / smtp.163.com
- 126 使用 imap.126.com / smtp.126.com
测试网易邮箱连接:
python3 scripts/test-163-imap.py your@163.com your_app_passwordbash4.0+jq- JSON 处理curl- HTTP 请求openssl- SSL/TLS 连接python3- IMAP/SMTP 处理(网易邮箱)gog- Gmail 操作(可选)
- Outlook 附件大小限制:< 3MB(直接附加),大文件请使用 OneDrive 分享
- 不支持 Exchange Server(仅 Outlook.com)
- 网易邮箱连接测试待实现
- 不支持 HTML 邮件编辑(仅纯文本)
- 2026-03-07: 初始版本
- 支持 Gmail、Outlook、网易邮箱
- 统一收发接口
- 账户管理功能
- JSON 输出格式
MIT License - see LICENSE
Huang Baixun (@huangbaixun)