通过 Zoho Mail REST API 读取、搜索和管理 Zoho 邮件
Zoho Mail Skill.是一项面向实际任务的技能,主要用于Read, scourse, 并直接从 Clawdbot 管理 Zoho Mail..;Setup. 前往 Zoho API 控制台并创建自客户端;
使用时应结合输入条件选择合适的执行方式,核对必要参数、依赖环境与输出内容,并按原始要求处理异常情况。从功能定位来看,该技能强调把分散的操作要求整理成清晰、可复用的处理流程,使用户能够围绕既定目标快速准备输入、选择执行方式并获得结构化结果。实际使用前应先确认任务范围、数据来源、运行环境、必要权限和关键参数,再依据技能说明逐步执行;若输入条件不完整,应先补齐信息或采用保守配置,避免因错误假设导致结果偏离需求。
执行过程中需要关注工具调用是否成功、接口或依赖是否可用、输出格式是否符合预期,并对异常提示、缺失字段和边界情况进行处理;涉及批量任务时,还应保存进度,避免中断后重复操作。该技能适合用于一次性任务,也可以接入自动化工作流,与其他技能或上层代理配合完成更完整的业务链路;在组合使用时,应明确每一步的输入输出关系,并避免不同步骤之间出现参数冲突。
直接通过 Clawdbot 读取、搜索和管理 Zoho Mail。
ZohoMail.messages.READ,ZohoMail.folders.READ,ZohoMail.accounts.READcurl -s -X POST "https://accounts.zoho.com/oauth/v2/token" -d "code=YOUR_GRANT_CODE" -d "client_id=YOUR_CLIENT_ID" -d "client_secret=YOUR_CLIENT_SECRET" -d "grant_type=authorization_code" | jq
export ZOHO_CLIENT_ID="your-client-id" export ZOHO_CLIENT_SECRET="your-client-secret" export ZOHO_REFRESH_TOKEN="your-refresh-token"
Zoho 使用 OAuth 2.0 认证机制。访问令牌(access token)有效期为 1 小时,因此每次调用 API 前都必须刷新;刷新令牌(refresh token)长期有效,除非被主动撤销。
ZOHO_ACCESS_TOKEN=$(curl -s -X POST "https://accounts.zoho.com/oauth/v2/token" -d "refresh_token=$ZOHO_REFRESH_TOKEN" -d "client_id=$ZOHO_CLIENT_ID" -d "client_secret=$ZOHO_CLIENT_SECRET" -d "grant_type=refresh_token" | jq -r '.access_token')
重要提示:请在每次 API 会话开始前执行该命令,或在收到 401 错误时立即执行。下方所有命令均假定 $ZOHO_ACCESS_TOKEN 已正确设置。
所有命令均使用 curl 并携带 Zoho-oauthtoken 认证请求头。注意:Zoho 使用的前缀是 Zoho-oauthtoken,不是 Bearer。
curl -s "https://mail.zoho.com/api/accounts"
-H "Authorization: Zoho-oauthtoken $ZOHO_ACCESS_TOKEN" | jq '.data[0] | {accountId, mailboxAddress, firstName, lastName}'
将账户 ID 存储为变量供后续调用使用:
ZOHO_ACCOUNT_ID=$(curl -s "https://mail.zoho.com/api/accounts" -H "Authorization: Zoho-oauthtoken $ZOHO_ACCESS_TOKEN" | jq -r '.data[0].accountId')
curl -s "https://mail.zoho.com/api/accounts/$ZOHO_ACCOUNT_ID/folders"
-H "Authorization: Zoho-oauthtoken $ZOHO_ACCESS_TOKEN" | jq '.data[] | {folderName, folderId, unreadCount, messageCount}'
INBOX_ID=$(curl -s "https://mail.zoho.com/api/accounts/$ZOHO_ACCOUNT_ID/folders" -H "Authorization: Zoho-oauthtoken $ZOHO_ACCESS_TOKEN" | jq -r '.data[] | select(.folderName=="Inbox") | .folderId')
curl -s "https://mail.zoho.com/api/accounts/$ZOHO_ACCOUNT_ID/messages/view?folderId=$INBOX_ID&limit=10&start=0"
-H "Authorization: Zoho-oauthtoken $ZOHO_ACCESS_TOKEN" | jq '.data[] | {subject, sender, fromAddress, receivedTime, messageId, status2}'
curl -s "https://mail.zoho.com/api/accounts/$ZOHO_ACCOUNT_ID/messages/view?folderId={folderId}&limit=10&start=0"
-H "Authorization: Zoho-oauthtoken $ZOHO_ACCESS_TOKEN" | jq '.data[] | {subject, sender, receivedTime, messageId}'
curl -s "https://mail.zoho.com/api/accounts/$ZOHO_ACCOUNT_ID/messages/{messageId}"
-H "Authorization: Zoho-oauthtoken $ZOHO_ACCESS_TOKEN" | jq '.data | {subject, sender, fromAddress, toAddress, ccAddress, receivedTime, content}'
curl -s "https://mail.zoho.com/api/accounts/$ZOHO_ACCOUNT_ID/messages/{messageId}/content"
-H "Authorization: Zoho-oauthtoken $ZOHO_ACCESS_TOKEN" | jq -r '.data.content'
curl -s "https://mail.zoho.com/api/accounts/$ZOHO_ACCOUNT_ID/messages/search?searchKey={query}&limit=10"
-H "Authorization: Zoho-oauthtoken $ZOHO_ACCESS_TOKEN" | jq '.data[] | {subject, sender, receivedTime, messageId, summary}'
搜索语法支持以下形式:
searchKey=invoicesearchKey=from:john@example.comsearchKey=subject:quarterly reportsearchKey=after:2024-01-01 before:2024-06-30searchKey=from:boss@company.com subject:meetingcurl -s "https://mail.zoho.com/api/accounts/$ZOHO_ACCOUNT_ID/threads/view?folderId=$INBOX_ID&limit=10&start=0"
-H "Authorization: Zoho-oauthtoken $ZOHO_ACCESS_TOKEN" | jq '.data[] | {subject, threadId, messageCount}'
curl -s "https://mail.zoho.com/api/accounts/$ZOHO_ACCOUNT_ID/threads/{threadId}"
-H "Authorization: Zoho-oauthtoken $ZOHO_ACCESS_TOKEN" | jq
curl -s "https://mail.zoho.com/api/accounts/$ZOHO_ACCOUNT_ID/tags"
-H "Authorization: Zoho-oauthtoken $ZOHO_ACCESS_TOKEN" | jq '.data[] | {tagName, tagId, color}'
curl -s "https://mail.zoho.com/api/accounts/$ZOHO_ACCOUNT_ID/folders/{folderId}/messages/{messageId}/attachments"
-H "Authorization: Zoho-oauthtoken $ZOHO_ACCESS_TOKEN" | jq '.data[] | {attachmentName, attachmentId, fileSize}'
curl -s "https://mail.zoho.com/api/accounts/$ZOHO_ACCOUNT_ID"
-H "Authorization: Zoho-oauthtoken $ZOHO_ACCESS_TOKEN" | jq '.data | {firstName, lastName, mailboxAddress, usedStorage, planStorage}'
若您的 Zoho 账户不在美国区域,请将 mail.zoho.com 和 accounts.zoho.com 替换为下表对应域名:
| 区域 | Mail API | Auth |
|---|---|---|
| US | mail.zoho.com | accounts.zoho.com |
| EU | mail.zoho.eu | accounts.zoho.eu |
| India | mail.zoho.in | accounts.zoho.in |
| Australia | mail.zoho.com.au | accounts.zoho.com.au |
| Japan | mail.zoho.jp | accounts.zoho.jp |
| Canada | mail.zohocloud.ca | accounts.zohocloud.ca |
receivedTime 字段单位为毫秒(自 Unix 纪元起),可使用如下命令转换为可读时间:date -d @$((receivedTime/1000))status2 字段含义:"0" 表示未读,"1" 表示已读Zoho-oauthtoken 前缀,不可使用 Bearer# 完整会话示例:刷新令牌、获取账户 ID、列出收件箱
ZOHO_ACCESS_TOKEN=$(curl -s -X POST "https://accounts.zoho.com/oauth/v2/token"
-d "refresh_token=$ZOHO_REFRESH_TOKEN"
-d "client_id=$ZOHO_CLIENT_ID"
-d "client_secret=$ZOHO_CLIENT_SECRET"
-d "grant_type=refresh_token" | jq -r '.access_token')
ZOHO_ACCOUNT_ID=$(curl -s "https://mail.zoho.com/api/accounts"
-H "Authorization: Zoho-oauthtoken $ZOHO_ACCESS_TOKEN" | jq -r '.data[0].accountId')
INBOX_ID=$(curl -s "https://mail.zoho.com/api/accounts/$ZOHO_ACCOUNT_ID/folders"
-H "Authorization: Zoho-oauthtoken $ZOHO_ACCESS_TOKEN" | jq -r '.data[] | select(.folderName=="Inbox") | .folderId')
# 列出最新的 5 封收件箱邮件
curl -s "https://mail.zoho.com/api/accounts/$ZOHO_ACCOUNT_ID/messages/view?folderId=$INBOX_ID&limit=5"
-H "Authorization: Zoho-oauthtoken $ZOHO_ACCESS_TOKEN" | jq '.data[] | {subject, sender, receivedTime}'
# 搜索来自某位联系人的邮件
curl -s "https://mail.zoho.com/api/accounts/$ZOHO_ACCOUNT_ID/messages/search?searchKey=from:monika@example.com&limit=5"
-H "Authorization: Zoho-oauthtoken $ZOHO_ACCESS_TOKEN" | jq '.data[] | {subject, sender, summary}'
# 获取各文件夹未读邮件数量(仅显示未读数大于 0 的文件夹)
curl -s "https://mail.zoho.com/api/accounts/$ZOHO_ACCOUNT_ID/folders"
-H "Authorization: Zoho-oauthtoken $ZOHO_ACCESS_TOKEN" | jq '.data[] | select(.unreadCount > 0) | {folderName, unreadCount}'
相关专题
热门下载
相关下载
精品课程
共6课时 | 54.7万人学习
共89课时 | 134.1万人学习
共49课时 | 82.6万人学习
最新文章