gmail

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Gmail

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 login
Check authentication status:
bash
python scripts/auth.py status
Logout 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 logout

Commands

命令

All operations via
scripts/gmail.py
. Auto-authenticates on first use if not logged in.
所有操作通过
scripts/gmail.py
执行。若未登录,首次使用时会自动触发认证。

Search Emails

搜索邮件

bash
undefined
bash
undefined

Search 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
undefined
python scripts/gmail.py search "subject:important" --include-spam-trash
undefined

Read Email Content

读取邮件内容

bash
undefined
bash
undefined

Get 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
undefined
python scripts/gmail.py get MESSAGE_ID --format minimal
undefined

Send Emails

发送邮件

bash
undefined
bash
undefined

Send 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"
python scripts/gmail.py send --to "user@example.com" --cc "cc@example.com" --bcc "bcc@example.com"
--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"
python scripts/gmail.py send --to "user@example.com" --subject "Hello" --body "Message"
--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
undefined
python scripts/gmail.py send --to "user@example.com" --subject "HTML Email"
--body "<h1>Hello</h1><p>HTML content</p>" --html
undefined

Draft Management

草稿管理

bash
undefined
bash
undefined

Create a draft

创建草稿

python scripts/gmail.py create-draft --to "user@example.com" --subject "Draft Subject"
--body "Draft content"
python scripts/gmail.py create-draft --to "user@example.com" --subject "Draft Subject"
--body "Draft content"

Send an existing draft

发送已有的草稿

python scripts/gmail.py send-draft DRAFT_ID
undefined
python scripts/gmail.py send-draft DRAFT_ID
undefined

Modify Messages (Labels)

修改消息(标签)

bash
undefined
bash
undefined

Mark 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
undefined
python scripts/gmail.py modify MESSAGE_ID --remove-label UNREAD --add-label STARRED
undefined

List Labels

列出标签

bash
undefined
bash
undefined

List all Gmail labels (system and user-created)

列出所有Gmail标签(系统标签和用户自定义标签)

python scripts/gmail.py list-labels
undefined
python scripts/gmail.py list-labels
undefined

Gmail Query Syntax

Gmail查询语法

Gmail supports powerful search operators:
QueryDescription
from:user@example.com
Emails from a specific sender
to:user@example.com
Emails to a specific recipient
subject:meeting
Emails with "meeting" in subject
is:unread
Unread emails
is:starred
Starred emails
is:important
Important emails
has:attachment
Emails with attachments
after:2024/01/01
Emails after a date
before:2024/12/31
Emails before a date
newer_than:7d
Emails from last 7 days
older_than:1m
Emails older than 1 month
label:work
Emails with a specific label
in:inbox
Emails in inbox
in:sent
Sent emails
in:trash
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支持强大的搜索操作符:
查询语句描述
from:user@example.com
来自特定发件人的邮件
to:user@example.com
发送给特定收件人的邮件
subject:meeting
主题包含"meeting"的邮件
is:unread
未读邮件
is:starred
已标星的邮件
is:important
标记为重要的邮件
has:attachment
带有附件的邮件
after:2024/01/01
2024年1月1日之后的邮件
before:2024/12/31
2024年12月31日之前的邮件
newer_than:7d
最近7天内的邮件
older_than:1m
超过1个月的邮件
label:work
带有特定标签的邮件
in:inbox
收件箱中的邮件
in:sent
已发送邮件
in:trash
已删除邮件
可通过空格(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

LabelID
Inbox
INBOX
Sent
SENT
Drafts
DRAFT
Spam
SPAM
Trash
TRASH
Starred
STARRED
Important
IMPORTANT
Unread
UNREAD
标签ID
收件箱
INBOX
已发送
SENT
草稿
DRAFT
垃圾邮件
SPAM
已删除
TRASH
已标星
STARRED
重要
IMPORTANT
未读
UNREAD

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-oauth
Tokens 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云函数自动刷新。