AgentMail MCP CLI
Email management for AI agents via the AgentMail API.
Documentation: https://docs.agentmail.to
Get API Key: https://agentmail.to
Prerequisites
Required:
Installation:
CODEBLOCK0
This installs the agentmail command globally.
Authentication
Set your API key (get one from agentmail.to):
CODEBLOCK1
Quick Reference
Inbox Management
CODEBLOCK2
Thread Management
CODEBLOCK3
Send Messages
CODEBLOCK4
Reply & Forward
CODEBLOCK5
Labels & Organization
CODEBLOCK6
Attachments
CODEBLOCK7
Available Commands
| Command | Description |
|---|
| INLINECODE1 | List all inboxes |
| INLINECODE2 |
Get inbox details |
|
inboxes create | Create new inbox |
|
inboxes delete <id> | Delete inbox |
|
threads list <inbox-id> | List threads |
|
threads get <inbox-id> <thread-id> | Get thread with messages |
|
messages send <inbox-id> | Send new email |
|
messages reply <inbox-id> <msg-id> | Reply to email |
|
messages forward <inbox-id> <msg-id> | Forward email |
|
messages update <inbox-id> <msg-id> | Update labels |
|
attachments get <thread-id> <att-id> | Get attachment |
Command Options Reference
inboxes list
- -
-l, --limit <n> - Max items (default: 10) - INLINECODE13 - Pagination token
inboxes create
- -
-u, --username <name> - Email username - INLINECODE15 - Email domain
- INLINECODE16 - Display name
threads list
- -
-l, --limit <n> - Max items (default: 10) - INLINECODE18 - Pagination token
- INLINECODE19 - Filter by labels (JSON array)
- INLINECODE20 - Before date (ISO 8601)
- INLINECODE21 - After date (ISO 8601)
messages send
- -
--to <email> - Recipient (repeatable) - INLINECODE23 - CC recipient (repeatable)
- INLINECODE24 - BCC recipient (repeatable)
- INLINECODE25 - Subject line
- INLINECODE26 - Plain text body
- INLINECODE27 - HTML body
- INLINECODE28 - Labels (JSON array)
messages reply
- -
-t, --text <body> - Plain text body - INLINECODE30 - HTML body
- INLINECODE31 - Reply to all recipients
- INLINECODE32 - Labels (JSON array)
messages forward
- -
--to <email> - Recipient (repeatable) - INLINECODE34 - CC recipient (repeatable)
- INLINECODE35 - BCC recipient (repeatable)
- INLINECODE36 - Subject line
- INLINECODE37 - Plain text body
- INLINECODE38 - HTML body
- INLINECODE39 - Labels (JSON array)
messages update
- -
--add-labels <json> - Labels to add (JSON array) - INLINECODE41 - Labels to remove (JSON array)
Common Workflows
Check for New Emails
CODEBLOCK8
Process and Archive Email
CODEBLOCK9
Auto-Reply Workflow
CODEBLOCK10
Create Inbox and Send First Email
CODEBLOCK11
Error Handling
If commands fail, check:
- 1. API Key: Ensure
AGENTMAIL_API_KEY is set - IDs: Verify inbox/thread/message IDs exist
- JSON: Use proper JSON for array options: INLINECODE43
Alternative: MCPorter Syntax
If the MCP compatibility is restored, you can also use MCPorter:
CODEBLOCK12
Links
- - API Documentation: https://docs.agentmail.to
- Get API Key: https://agentmail.to
- MCP Server: https://github.com/agentmail-to/agentmail-mcp
- Node SDK: https://github.com/agentmail-to/agentmail-node
AgentMail MCP CLI
通过AgentMail API为AI代理提供电子邮件管理。
文档: https://docs.agentmail.to
获取API密钥: https://agentmail.to
前提条件
必需:
安装:
bash
npm install -g openclaw-agentmail-cli
这将全局安装 agentmail 命令。
身份验证
设置您的API密钥(从 agentmail.to 获取):
bash
选项1:环境变量(推荐)
export AGENTMAIL
APIKEY=your
apikey
agentmail inboxes list
选项2:CLI参数
agentmail --api-key your
apikey inboxes list
快速参考
收件箱管理
bash
列出所有收件箱
agentmail inboxes list
限制数量列出
agentmail inboxes list --limit 5
创建新收件箱
agentmail inboxes create --display-name My Agent
使用用户名和域名创建
agentmail inboxes create --username myagent --domain agentmail.to --display-name My Agent
获取收件箱详情
agentmail inboxes get
删除收件箱(不可恢复!)
agentmail inboxes delete
线程管理
bash
列出收件箱中的线程
agentmail threads list
带选项列出
agentmail threads list --limit 10
按标签筛选
agentmail threads list --labels [unread]
按日期筛选
agentmail threads list --after 2024-01-01 --before 2024-12-31
获取线程详情(包含所有消息)
agentmail threads get
发送消息
bash
发送简单邮件
agentmail messages send \
--to user@example.com \
--subject Hello \
--text Email body here
发送给多个收件人
agentmail messages send \
--to user1@example.com \
--to user2@example.com \
--subject Team Update \
--text Hello team...
带抄送和密送发送
agentmail messages send \
--to primary@example.com \
--cc copy@example.com \
--bcc hidden@example.com \
--subject Important \
--text Please review...
发送HTML邮件
agentmail messages send \
--to user@example.com \
--subject Newsletter \
--html Hello
HTML content
带标签发送
agentmail messages send \
--to user@example.com \
--subject Outreach \
--text Hello... \
--labels [campaign,outbound]
回复与转发
bash
回复消息
agentmail messages reply \
--text Thank you for your email.
使用HTML回复
agentmail messages reply \
--html Thank you!
回复所有人
agentmail messages reply \
--text Replying to everyone... \
--reply-all
转发消息
agentmail messages forward \
--to forward-to@example.com \
--text FYI - see below
转发给多人
agentmail messages forward \
--to team@example.com \
--cc manager@example.com \
--subject Fwd: Customer Inquiry \
--text Please review
标签与组织
bash
为消息添加标签
agentmail messages update \
--add-labels [important,needs-review]
移除标签
agentmail messages update \
--remove-labels [unread]
同时添加和移除
agentmail messages update \
--add-labels [processed] \
--remove-labels [unread,pending]
附件
bash
获取附件详情和下载URL
agentmail attachments get
可用命令
| 命令 | 描述 |
|---|
| inboxes list | 列出所有收件箱 |
| inboxes get <id> |
获取收件箱详情 |
| inboxes create | 创建新收件箱 |
| inboxes delete | 删除收件箱 |
| threads list | 列出线程 |
| threads get | 获取带消息的线程 |
| messages send | 发送新邮件 |
| messages reply | 回复邮件 |
| messages forward | 转发邮件 |
| messages update | 更新标签 |
| attachments get | 获取附件 |
命令选项参考
inboxes list
- - -l, --limit - 最大数量(默认:10)
- --page-token - 分页令牌
inboxes create
- - -u, --username - 电子邮件用户名
- -d, --domain - 电子邮件域名
- -n, --display-name - 显示名称
threads list
- - -l, --limit - 最大数量(默认:10)
- --page-token - 分页令牌
- --labels - 按标签筛选(JSON数组)
- --before - 之前日期(ISO 8601)
- --after - 之后日期(ISO 8601)
messages send
- - --to - 收件人(可重复)
- --cc - 抄送收件人(可重复)
- --bcc - 密送收件人(可重复)
- -s, --subject - 主题行
- -t, --text - 纯文本正文
- --html - HTML正文
- --labels - 标签(JSON数组)
messages reply
- - -t, --text - 纯文本正文
- --html - HTML正文
- --reply-all - 回复所有收件人
- --labels - 标签(JSON数组)
messages forward
- - --to - 收件人(可重复)
- --cc - 抄送收件人(可重复)
- --bcc - 密送收件人(可重复)
- -s, --subject - 主题行
- -t, --text - 纯文本正文
- --html - HTML正文
- --labels - 标签(JSON数组)
messages update
- - --add-labels - 要添加的标签(JSON数组)
- --remove-labels - 要移除的标签(JSON数组)
常见工作流程
检查新邮件
bash
列出未读线程
agentmail threads list --labels [unread] --limit 20
处理并归档邮件
bash
1. 获取线程
agentmail threads get
2. 处理内容(您的逻辑)
3. 标记为已处理
agentmail messages update \
--add-labels [processed] \
--remove-labels [unread]
自动回复工作流程
bash
1. 检查需要回复的邮件
agentmail threads list --labels [needs-reply]
2. 获取线程详情
agentmail threads get
3. 发送回复
agentmail messages reply \
--text Thank you for reaching