gmail
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGmail
Gmail
Lightweight Gmail integration with standalone OAuth authentication. No MCP server required.
⚠️ Requires Google Workspace account. Personal Gmail accounts are not supported.
轻量级Gmail集成工具,支持独立OAuth认证,无需MCP服务器。
⚠️ 需使用Google Workspace账户。 个人Gmail账户不支持。
First-Time Setup
首次设置
Authenticate with Google (opens browser):
bash
python scripts/auth.py loginCheck authentication status:
bash
python scripts/auth.py statusLogout when needed:
bash
python scripts/auth.py logout通过Google进行认证(将打开浏览器):
bash
python scripts/auth.py login检查认证状态:
bash
python scripts/auth.py status需要时登出:
bash
python scripts/auth.py logoutCommands
命令
All operations via . Auto-authenticates on first use if not logged in.
scripts/gmail.py所有操作通过执行。若未登录,首次使用时会自动触发认证。
scripts/gmail.pySearch Emails
搜索邮件
bash
undefinedbash
undefinedSearch with Gmail query syntax
使用Gmail查询语法进行搜索
python scripts/gmail.py search "from:someone@example.com is:unread"
python scripts/gmail.py search "from:someone@example.com is:unread"
Search recent emails (no query returns all)
搜索近期邮件(无查询条件时返回全部邮件)
python scripts/gmail.py search --limit 20
python scripts/gmail.py search --limit 20
Filter by label
按标签筛选
python scripts/gmail.py search --label INBOX --limit 10
python scripts/gmail.py search --label INBOX --limit 10
Include spam and trash
包含垃圾邮件和已删除邮件
python scripts/gmail.py search "subject:important" --include-spam-trash
undefinedpython scripts/gmail.py search "subject:important" --include-spam-trash
undefinedRead Email Content
读取邮件内容
bash
undefinedbash
undefinedGet full message content
获取完整邮件内容
python scripts/gmail.py get MESSAGE_ID
python scripts/gmail.py get MESSAGE_ID
Get just metadata (headers)
仅获取元数据(邮件头)
python scripts/gmail.py get MESSAGE_ID --format metadata
python scripts/gmail.py get MESSAGE_ID --format metadata
Get minimal response (IDs only)
获取极简响应(仅ID)
python scripts/gmail.py get MESSAGE_ID --format minimal
undefinedpython scripts/gmail.py get MESSAGE_ID --format minimal
undefinedSend Emails
发送邮件
bash
undefinedbash
undefinedSend a simple email
发送简单邮件
python scripts/gmail.py send --to "user@example.com" --subject "Hello" --body "Message body"
python scripts/gmail.py send --to "user@example.com" --subject "Hello" --body "Message body"
Send with CC and BCC
发送带抄送和密送的邮件
python scripts/gmail.py send --to "user@example.com" --cc "cc@example.com" --bcc "bcc@example.com"
--subject "Team Update" --body "Update message"
--subject "Team Update" --body "Update message"
python scripts/gmail.py send --to "user@example.com" --cc "cc@example.com" --bcc "bcc@example.com"
--subject "Team Update" --body "Update message"
--subject "Team Update" --body "Update message"
Send from an alias (must be configured in Gmail settings)
使用别名发送(需在Gmail设置中配置别名)
python scripts/gmail.py send --to "user@example.com" --subject "Hello" --body "Message"
--from "Mile9 Accounts accounts@mile9.io"
--from "Mile9 Accounts accounts@mile9.io"
python scripts/gmail.py send --to "user@example.com" --subject "Hello" --body "Message"
--from "Mile9 Accounts accounts@mile9.io"
--from "Mile9 Accounts accounts@mile9.io"
Send HTML email
发送HTML格式邮件
python scripts/gmail.py send --to "user@example.com" --subject "HTML Email"
--body "<h1>Hello</h1><p>HTML content</p>" --html
--body "<h1>Hello</h1><p>HTML content</p>" --html
undefinedpython scripts/gmail.py send --to "user@example.com" --subject "HTML Email"
--body "<h1>Hello</h1><p>HTML content</p>" --html
--body "<h1>Hello</h1><p>HTML content</p>" --html
undefinedDraft Management
草稿管理
bash
undefinedbash
undefinedCreate a draft
创建草稿
python scripts/gmail.py create-draft --to "user@example.com" --subject "Draft Subject"
--body "Draft content"
--body "Draft content"
python scripts/gmail.py create-draft --to "user@example.com" --subject "Draft Subject"
--body "Draft content"
--body "Draft content"
Send an existing draft
发送已有的草稿
python scripts/gmail.py send-draft DRAFT_ID
undefinedpython scripts/gmail.py send-draft DRAFT_ID
undefinedModify Messages (Labels)
修改消息(标签)
bash
undefinedbash
undefinedMark as read (remove UNREAD label)
标记为已读(移除UNREAD标签)
python scripts/gmail.py modify MESSAGE_ID --remove-label UNREAD
python scripts/gmail.py modify MESSAGE_ID --remove-label UNREAD
Mark as unread
标记为未读
python scripts/gmail.py modify MESSAGE_ID --add-label UNREAD
python scripts/gmail.py modify MESSAGE_ID --add-label UNREAD
Archive (remove from INBOX)
归档(从收件箱移除)
python scripts/gmail.py modify MESSAGE_ID --remove-label INBOX
python scripts/gmail.py modify MESSAGE_ID --remove-label INBOX
Star a message
为邮件标星
python scripts/gmail.py modify MESSAGE_ID --add-label STARRED
python scripts/gmail.py modify MESSAGE_ID --add-label STARRED
Unstar a message
取消邮件标星
python scripts/gmail.py modify MESSAGE_ID --remove-label STARRED
python scripts/gmail.py modify MESSAGE_ID --remove-label STARRED
Mark as important
标记为重要
python scripts/gmail.py modify MESSAGE_ID --add-label IMPORTANT
python scripts/gmail.py modify MESSAGE_ID --add-label IMPORTANT
Multiple label changes at once
同时修改多个标签
python scripts/gmail.py modify MESSAGE_ID --remove-label UNREAD --add-label STARRED
undefinedpython scripts/gmail.py modify MESSAGE_ID --remove-label UNREAD --add-label STARRED
undefinedList Labels
列出标签
bash
undefinedbash
undefinedList all Gmail labels (system and user-created)
列出所有Gmail标签(系统标签和用户自定义标签)
python scripts/gmail.py list-labels
undefinedpython scripts/gmail.py list-labels
undefinedGmail Query Syntax
Gmail查询语法
Gmail supports powerful search operators:
| Query | Description |
|---|---|
| Emails from a specific sender |
| Emails to a specific recipient |
| Emails with "meeting" in subject |
| Unread emails |
| Starred emails |
| Important emails |
| Emails with attachments |
| Emails after a date |
| Emails before a date |
| Emails from last 7 days |
| Emails older than 1 month |
| Emails with a specific label |
| Emails in inbox |
| Sent emails |
| Trashed emails |
Combine with AND (space), OR, or - (NOT):
bash
python scripts/gmail.py search "from:boss@company.com is:unread newer_than:1d"
python scripts/gmail.py search "subject:urgent OR subject:important"
python scripts/gmail.py search "from:newsletter@example.com -is:starred"Gmail支持强大的搜索操作符:
| 查询语句 | 描述 |
|---|---|
| 来自特定发件人的邮件 |
| 发送给特定收件人的邮件 |
| 主题包含"meeting"的邮件 |
| 未读邮件 |
| 已标星的邮件 |
| 标记为重要的邮件 |
| 带有附件的邮件 |
| 2024年1月1日之后的邮件 |
| 2024年12月31日之前的邮件 |
| 最近7天内的邮件 |
| 超过1个月的邮件 |
| 带有特定标签的邮件 |
| 收件箱中的邮件 |
| 已发送邮件 |
| 已删除邮件 |
可通过空格(AND)、OR或-(NOT)组合多个条件:
bash
python scripts/gmail.py search "from:boss@company.com is:unread newer_than:1d"
python scripts/gmail.py search "subject:urgent OR subject:important"
python scripts/gmail.py search "from:newsletter@example.com -is:starred"Common Label IDs
常用标签ID
| Label | ID |
|---|---|
| Inbox | |
| Sent | |
| Drafts | |
| Spam | |
| Trash | |
| Starred | |
| Important | |
| Unread | |
| 标签 | ID |
|---|---|
| 收件箱 | |
| 已发送 | |
| 草稿 | |
| 垃圾邮件 | |
| 已删除 | |
| 已标星 | |
| 重要 | |
| 未读 | |
Token Management
令牌管理
Tokens stored securely using the system keyring:
- macOS: Keychain
- Windows: Windows Credential Locker
- Linux: Secret Service API (GNOME Keyring, KDE Wallet, etc.)
Service name:
gmail-skill-oauthTokens automatically refresh when expired using Google's cloud function.
令牌通过系统密钥环安全存储:
- macOS: Keychain
- Windows: Windows Credential Locker
- Linux: Secret Service API(GNOME Keyring、KDE Wallet等)
服务名称:
gmail-skill-oauth令牌过期时会通过Google云函数自动刷新。