email-automation

邮箱自动化:读取、搜索、草拟和发送邮件,支持 Gmail API 以及通用 IMAP/SMTP 流程。

33 stars

Best use case

email-automation is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

邮箱自动化:读取、搜索、草拟和发送邮件,支持 Gmail API 以及通用 IMAP/SMTP 流程。

Teams using email-automation should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/email-automation/SKILL.md --create-dirs "https://raw.githubusercontent.com/aAAaqwq/AGI-Super-Team/main/skills/email-automation/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/email-automation/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How email-automation Compares

Feature / Agentemail-automationStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

邮箱自动化:读取、搜索、草拟和发送邮件,支持 Gmail API 以及通用 IMAP/SMTP 流程。

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Email Automation Skill

- Author: Daniel Li
- Copyright © Daniel Li. All rights reserved.

邮箱自动化:读取、搜索、草拟、发送邮件。

## 支持的方式

### 方式 1: Gmail API (推荐)

**优点**: 功能完整,支持标签、搜索、草稿
**配置步骤**:

1. 访问 [Google Cloud Console](https://console.cloud.google.com/)
2. 创建项目 → 启用 Gmail API
3. 创建 OAuth 2.0 凭据(桌面应用)
4. 下载 `credentials.json`
5. 存储到 `~/.config/gmail/credentials.json`

```bash
# 安装依赖
pip3 install google-auth-oauthlib google-api-python-client

# 首次授权(会打开浏览器)
python3 ~/clawd/skills/email-automation/gmail_auth.py
```

### 方式 2: IMAP/SMTP (通用)

**优点**: 支持任何邮箱
**配置**:

```bash
# 存储凭据
pass insert email/gmail-address    # 邮箱地址
pass insert email/gmail-app-pass   # 应用专用密码(非登录密码)
```

Gmail 应用专用密码获取:
1. 访问 https://myaccount.google.com/apppasswords
2. 选择"邮件" + "其他设备"
3. 生成 16 位密码

### 方式 3: n8n 工作流

使用 n8n 的 Gmail/IMAP 节点,通过 webhook 触发。

---

## 核心功能

### 读取邮件

```python
# gmail_read.py
from googleapiclient.discovery import build
from google.oauth2.credentials import Credentials

creds = Credentials.from_authorized_user_file('token.json')
service = build('gmail', 'v1', credentials=creds)

# 获取最新 10 封邮件
results = service.users().messages().list(
    userId='me', maxResults=10, q='is:unread'
).execute()

for msg in results.get('messages', []):
    detail = service.users().messages().get(
        userId='me', id=msg['id'], format='metadata'
    ).execute()
    headers = {h['name']: h['value'] for h in detail['payload']['headers']}
    print(f"From: {headers.get('From')}")
    print(f"Subject: {headers.get('Subject')}")
    print("---")
```

### 搜索邮件

```python
# Gmail 搜索语法
queries = {
    "未读": "is:unread",
    "今天": "newer_than:1d",
    "重要": "is:important",
    "带附件": "has:attachment",
    "来自某人": "from:someone@example.com",
    "主题包含": "subject:关键词",
}
```

### 发送邮件

```python
# gmail_send.py
import base64
from email.mime.text import MIMEText

def create_message(to, subject, body):
    message = MIMEText(body)
    message['to'] = to
    message['subject'] = subject
    raw = base64.urlsafe_b64encode(message.as_bytes()).decode()
    return {'raw': raw}

def send_email(service, to, subject, body):
    message = create_message(to, subject, body)
    service.users().messages().send(userId='me', body=message).execute()
```

### IMAP 方式(备选)

```python
import imaplib
import email

# 连接
mail = imaplib.IMAP4_SSL('imap.gmail.com')
mail.login(EMAIL, APP_PASSWORD)
mail.select('inbox')

# 搜索未读
status, messages = mail.search(None, 'UNSEEN')
for num in messages[0].split():
    status, data = mail.fetch(num, '(RFC822)')
    msg = email.message_from_bytes(data[0][1])
    print(f"From: {msg['from']}")
    print(f"Subject: {msg['subject']}")
```

---

## 安全策略

### 权限分层(参考 SECURITY.md)

| 操作 | 权限级别 |
|------|----------|
| 读取邮件列表 | 🟢 自由 |
| 读取邮件内容 | 🟢 自由 |
| 搜索邮件 | 🟢 自由 |
| 创建草稿 | 🟢 自由 |
| 发送邮件 | 🟡 需确认 |
| 删除邮件 | 🟡 需确认 |
| 修改标签 | 🟢 自由 |

### 发送确认流程

```
⚠️ 需要确认发送邮件:

收件人: xxx@example.com
主题: Re: 关于项目进度
内容预览:
---
你好,

关于项目进度...
---

回复 "确认" 发送,或 "取消" 放弃
```

---

## 自动化场景

### 1. 邮件摘要(每日)

```
每天早上检查未读邮件,生成摘要推送到 Telegram
```

### 2. 重要邮件提醒

```
监控特定发件人/关键词,立即通知
```

### 3. 自动回复草稿

```
收到邮件后自动生成回复草稿,等待确认后发送
```

---

## 配置清单

完成配置后,在 TOOLS.md 中记录:

```markdown
### Email
- Provider: Gmail
- Address: xxx@gmail.com
- Auth: OAuth 2.0 / App Password
- Token: ~/.config/gmail/token.json
- 权限: 读取 ✅ | 发送 ⚠️需确认
```

---

## 相关文件

- `gmail_auth.py` - OAuth 授权脚本
- `gmail_read.py` - 读取邮件
- `gmail_send.py` - 发送邮件
- `SECURITY.md` - 安全策略

Related Skills

zoom-automation

33
from aAAaqwq/AGI-Super-Team

Automate Zoom meeting creation, management, recordings, webinars, and participant tracking via Rube MCP (Composio). Always search tools first for current schemas.

zoho-crm-automation

33
from aAAaqwq/AGI-Super-Team

Automate Zoho CRM tasks via Rube MCP (Composio): create/update records, search contacts, manage leads, and convert leads. Always search tools first for current schemas.

zendesk-automation

33
from aAAaqwq/AGI-Super-Team

Automate Zendesk tasks via Rube MCP (Composio): tickets, users, organizations, replies. Always search tools first for current schemas.

youtube-automation

33
from aAAaqwq/AGI-Super-Team

Automate YouTube tasks via Rube MCP (Composio): upload videos, manage playlists, search content, get analytics, and handle comments. Always search tools first for current schemas.

workflow-automation

33
from aAAaqwq/AGI-Super-Team

Workflow automation is the infrastructure that makes AI agents reliable. Without durable execution, a network hiccup during a 10-step payment flow means lost money and angry customers. With it, workflows resume exactly where they left off. This skill covers the platforms (n8n, Temporal, Inngest) and patterns (sequential, parallel, orchestrator-worker) that turn brittle scripts into production-grade automation. Key insight: The platforms make different tradeoffs. n8n optimizes for accessibility

whatsapp-automation

33
from aAAaqwq/AGI-Super-Team

Automate WhatsApp Business tasks via Rube MCP (Composio): send messages, manage templates, upload media, and handle contacts. Always search tools first for current schemas.

wecom-cs-automation

33
from aAAaqwq/AGI-Super-Team

企业微信客服自动化系统。自动同意好友添加、基于知识库的智能问答、未知问题人工介入提醒。适用于企业微信客服场景的 AI 助手机器人。

wecom-automation

33
from aAAaqwq/AGI-Super-Team

企业微信个人账号直连自动化。基于 Wechaty 框架实现企业微信消息接收、自动同意好友、知识库问答、人工介入提醒。适用于企业微信个人机器人和自动化助手场景。

webflow-automation

33
from aAAaqwq/AGI-Super-Team

Automate Webflow CMS collections, site publishing, page management, asset uploads, and ecommerce orders via Rube MCP (Composio). Always search tools first for current schemas.

web-scraping-automation

33
from aAAaqwq/AGI-Super-Team

自动化爬取网站数据和 API 接口。当用户需要抓取网页内容、调用 API、解析数据或创建爬虫脚本时使用此技能。

vercel-automation

33
from aAAaqwq/AGI-Super-Team

Automate Vercel tasks via Rube MCP (Composio): manage deployments, domains, DNS, env vars, projects, and teams. Always search tools first for current schemas.

twitter-automation

33
from aAAaqwq/AGI-Super-Team

Automate Twitter/X tasks via Rube MCP (Composio): posts, search, users, bookmarks, lists, media. Always search tools first for current schemas.