gmail by sanjay3290/ai-skills
npx skills add https://github.com/sanjay3290/ai-skills --skill gmail轻量级 Gmail 集成,具备独立的 OAuth 身份验证。无需 MCP 服务器。
⚠️ 需要 Google Workspace 账户。 不支持个人 Gmail 账户。
使用 Google 进行身份验证(打开浏览器):
python scripts/auth.py login
检查身份验证状态:
python scripts/auth.py status
需要时注销:
python scripts/auth.py logout
所有操作均通过 scripts/gmail.py 进行。如果未登录,首次使用时将自动进行身份验证。
# 使用 Gmail 查询语法进行搜索
python scripts/gmail.py search "from:someone@example.com is:unread"
# 搜索最近的邮件(无查询条件则返回所有邮件)
python scripts/gmail.py search --limit 20
# 按标签筛选
python scripts/gmail.py search --label INBOX --limit 10
# 包含垃圾邮件和已删除邮件
python scripts/gmail.py search "subject:important" --include-spam-trash
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
# 获取完整的邮件内容
python scripts/gmail.py get MESSAGE_ID
# 仅获取元数据(邮件头)
python scripts/gmail.py get MESSAGE_ID --format metadata
# 获取最小化响应(仅 ID)
python scripts/gmail.py get MESSAGE_ID --format minimal
# 发送简单邮件
python scripts/gmail.py send --to "user@example.com" --subject "Hello" --body "Message body"
# 发送带抄送和密送的邮件
python scripts/gmail.py send --to "user@example.com" --cc "cc@example.com" --bcc "bcc@example.com" \
--subject "Team Update" --body "Update message"
# 从别名发送(必须在 Gmail 设置中配置)
python scripts/gmail.py send --to "user@example.com" --subject "Hello" --body "Message" \
--from "Mile9 Accounts <accounts@mile9.io>"
# 发送 HTML 邮件
python scripts/gmail.py send --to "user@example.com" --subject "HTML Email" \
--body "<h1>Hello</h1><p>HTML content</p>" --html
# 创建草稿
python scripts/gmail.py create-draft --to "user@example.com" --subject "Draft Subject" \
--body "Draft content"
# 发送现有草稿
python scripts/gmail.py send-draft DRAFT_ID
# 标记为已读(移除 UNREAD 标签)
python scripts/gmail.py modify MESSAGE_ID --remove-label UNREAD
# 标记为未读
python scripts/gmail.py modify MESSAGE_ID --add-label UNREAD
# 归档(从收件箱移除)
python scripts/gmail.py modify MESSAGE_ID --remove-label INBOX
# 为邮件加星标
python scripts/gmail.py modify MESSAGE_ID --add-label STARRED
# 取消邮件星标
python scripts/gmail.py modify MESSAGE_ID --remove-label STARRED
# 标记为重要
python scripts/gmail.py modify MESSAGE_ID --add-label IMPORTANT
# 同时进行多个标签更改
python scripts/gmail.py modify MESSAGE_ID --remove-label UNREAD --add-label STARRED
# 列出所有 Gmail 标签(系统标签和用户创建的标签)
python scripts/gmail.py list-labels
Gmail 支持强大的搜索运算符:
| 查询 | 描述 |
|---|---|
from:user@example.com | 来自特定发件人的邮件 |
to:user@example.com | 发送给特定收件人的邮件 |
subject:meeting | 主题中包含 "meeting" 的邮件 |
is:unread | 未读邮件 |
is:starred | 已加星标的邮件 |
is:important | 重要邮件 |
has:attachment | 带有附件的邮件 |
after:2024/01/01 | 某个日期之后的邮件 |
before:2024/12/31 | 某个日期之前的邮件 |
newer_than:7d | 最近 7 天内的邮件 |
older_than:1m | 超过 1 个月的邮件 |
label:work | 带有特定标签的邮件 |
in:inbox | 收件箱中的邮件 |
in:sent | 已发送的邮件 |
in:trash | 已删除的邮件 |
使用 AND(空格)、OR 或 -(NOT)进行组合:
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"
| 标签 | ID |
|---|---|
| 收件箱 | INBOX |
| 已发送 | SENT |
| 草稿 | DRAFT |
| 垃圾邮件 | SPAM |
| 已删除邮件 | TRASH |
| 已加星标 | STARRED |
| 重要 | IMPORTANT |
| 未读 | UNREAD |
令牌使用系统密钥环安全存储:
服务名称:gmail-skill-oauth
令牌过期时会使用 Google 的云函数自动刷新。
每周安装数
101
代码仓库
GitHub 星标数
173
首次出现
2026 年 1 月 23 日
安全审计
安装于
codex88
opencode87
gemini-cli87
cursor83
github-copilot81
claude-code77
Lightweight Gmail integration with standalone OAuth authentication. No MCP server required.
⚠️ Requires Google Workspace account. Personal Gmail accounts are not supported.
Authenticate with Google (opens browser):
python scripts/auth.py login
Check authentication status:
python scripts/auth.py status
Logout when needed:
python scripts/auth.py logout
All operations via scripts/gmail.py. Auto-authenticates on first use if not logged in.
# Search with Gmail query syntax
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
# Filter by label
python scripts/gmail.py search --label INBOX --limit 10
# Include spam and trash
python scripts/gmail.py search "subject:important" --include-spam-trash
# Get full message content
python scripts/gmail.py get MESSAGE_ID
# Get just metadata (headers)
python scripts/gmail.py get MESSAGE_ID --format metadata
# Get minimal response (IDs only)
python scripts/gmail.py get MESSAGE_ID --format minimal
# Send a simple email
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"
# Send from an alias (must be configured in Gmail settings)
python scripts/gmail.py send --to "user@example.com" --subject "Hello" --body "Message" \
--from "Mile9 Accounts <accounts@mile9.io>"
# Send HTML email
python scripts/gmail.py send --to "user@example.com" --subject "HTML Email" \
--body "<h1>Hello</h1><p>HTML content</p>" --html
# Create a draft
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
# Mark as read (remove UNREAD label)
python scripts/gmail.py modify MESSAGE_ID --remove-label UNREAD
# Mark as 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
# Star a message
python scripts/gmail.py modify MESSAGE_ID --add-label STARRED
# Unstar a message
python scripts/gmail.py modify MESSAGE_ID --remove-label STARRED
# Mark as 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
# List all Gmail labels (system and user-created)
python scripts/gmail.py list-labels
Gmail supports powerful search operators:
| Query | Description |
|---|---|
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 |
Combine with AND (space), OR, or - (NOT):
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"
| Label | ID |
|---|---|
| Inbox | INBOX |
| Sent | SENT |
| Drafts | DRAFT |
| Spam | SPAM |
| Trash | TRASH |
| Starred | STARRED |
| Important |
Tokens stored securely using the system keyring:
Service name: gmail-skill-oauth
Tokens automatically refresh when expired using Google's cloud function.
Weekly Installs
101
Repository
GitHub Stars
173
First Seen
Jan 23, 2026
Security Audits
Gen Agent Trust HubPassSocketWarnSnykFail
Installed on
codex88
opencode87
gemini-cli87
cursor83
github-copilot81
claude-code77
Skills CLI 使用指南:AI Agent 技能包管理器安装与管理教程
40,000 周安装
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 |
IMPORTANT| Unread | UNREAD |