← 返回 Skills 市场
yiweiweilai

Email Operations

作者 yiweiweilai · GitHub ↗ · v2.0.1 · MIT-0
cross-platform ⚠ suspicious
133
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install email-operations
功能描述
邮件操作技能,通过 SMTP/IMAP 协议读取和发送邮件。当用户想要查看邮件、搜索邮件内容、 获取收件箱列表、拉取特定邮件详情、发送邮件、或需要与邮箱服务交互时,使用此技能。 无论用户是否明确提到 "IMAP" 或 "SMTP",只要涉及邮件收发操作,均可触发此技能。 适用场景:查看收件箱、搜索邮件、按条件过滤...
使用说明 (SKILL.md)

Email Operations Skill

通过 SMTP/IMAP 协议读取和管理邮件的技能,支持邮件收发全流程操作。

凭证配置

重要:凭证存储在技能目录下的 .env 文件中,而非系统环境变量。

使用此技能前,请先配置 skills/email-operations/.env 文件:

# 邮箱基础配置
[email protected]
EMAIL_IMAP_PASSWORD=your_imap_password
EMAIL_SMTP_PASSWORD=your_smtp_password

# IMAP 服务器配置(可选,有默认值)
EMAIL_IMAP_HOST=imap.gmail.com
EMAIL_IMAP_PORT=993

# SMTP 服务器配置(可选,有默认值)
EMAIL_SMTP_HOST=smtp.gmail.com
EMAIL_SMTP_PORT=587
EMAIL_SMTP_SSL=false

常用邮件服务配置

Gmail:

[email protected]
EMAIL_IMAP_HOST=imap.gmail.com
EMAIL_IMAP_PORT=993
EMAIL_SMTP_HOST=smtp.gmail.com
EMAIL_SMTP_PORT=587

注意:需要开启"应用专用密码"

QQ/foxmail:

[email protected]
EMAIL_IMAP_HOST=imap.qq.com
EMAIL_IMAP_PORT=993
EMAIL_SMTP_HOST=smtp.qq.com
EMAIL_SMTP_PORT=587
EMAIL_SMTP_SSL=false

163/188:

[email protected]
EMAIL_IMAP_HOST=imap.163.com
EMAIL_IMAP_PORT=993
EMAIL_SMTP_HOST=smtp.163.com
EMAIL_SMTP_PORT=465
EMAIL_SMTP_SSL=true

Outlook:

[email protected]
EMAIL_IMAP_HOST=outlook.office365.com
EMAIL_IMAP_PORT=993
EMAIL_SMTP_HOST=smtp.office365.com
EMAIL_SMTP_PORT=587

核心功能

读取邮件

功能 方法 说明
获取收件箱 get_inbox() 返回邮件列表摘要
获取详情 get_email() 返回完整邮件内容
搜索邮件 search_emails() 按关键词/发件人/日期搜索
保存附件 save_attachment() 下载附件到本地
文件夹列表 get_folders() 获取邮箱文件夹

发送邮件

功能 方法 说明
发送文本邮件 send_email() 发送纯文本邮件
发送HTML邮件 send_html_email() 发送 HTML 格式邮件
发送带附件 send_email_with_attachments() 添加附件发送

使用示例

读取邮件

from scripts.email_client import EmailClient

client = EmailClient()

# 获取收件箱邮件列表
emails = client.get_inbox(count=10)
for email in emails:
    print(f"主题: {email['subject']}")
    print(f"发件人: {email['from']}")
    print(f"时间: {email['date']}")
    print("---")

# 按 UID 获取邮件详情
email = client.get_email(uid=123)
print(f"正文: {email['body']['plain']}")
print(f"附件: {email['attachments']}")

# 搜索邮件
results = client.search_emails(
    keyword="发票",
    from_addr="[email protected]",
    date_from="2024-01-01",
    date_to="2024-12-31"
)

发送邮件

# 发送文本邮件
client.send_email(
    to="[email protected]",
    subject="邮件主题",
    body="这是邮件正文内容"
)

# 发送 HTML 邮件
client.send_html_email(
    to="[email protected]",
    subject="HTML 邮件",
    html_body="\x3Ch1>标题\x3C/h1>\x3Cp>正文内容\x3C/p>"
)

# 发送带附件的邮件
client.send_email_with_attachments(
    to="[email protected]",
    subject="带附件的邮件",
    body="请查收附件",
    attachments=[
        "./files/document.pdf",
        "./files/image.png"
    ]
)

# 群发邮件
recipients = ["[email protected]", "[email protected]", "[email protected]"]
for recipient in recipients:
    client.send_email(
        to=recipient,
        subject="群发邮件",
        body="这是一封群发邮件"
    )

EmailClient 方法列表

读取操作

方法 说明 参数
get_inbox() 获取收件箱邮件列表 count=10, offset=0, folder="INBOX"
get_email() 获取单封邮件详情 uid, folder="INBOX"
search_emails() 搜索邮件 keyword, from_addr, to_addr, date_from, date_to, folder
save_attachment() 保存附件 email_uid, attachment_index, save_path
get_folders() 获取文件夹列表

发送操作

方法 说明 参数
send_email() 发送文本邮件 to, subject, body, cc=None, bcc=None
send_html_email() 发送HTML邮件 to, subject, html_body, cc=None, bcc=None
send_email_with_attachments() 发送带附件邮件 to, subject, body, attachments, cc, bcc

数据结构

邮件摘要 (get_inbox 返回)

{
    "uid": 12345,
    "subject": "邮件主题",
    "from": "[email protected]",
    "from_name": "发件人姓名",
    "to": "[email protected]",
    "date": "2024-01-15 10:30:00",
    "size": 1024,
    "flags": ["已读", "星标"],
    "is_read": True
}

邮件详情 (get_email 返回)

{
    "uid": 12345,
    "subject": "邮件主题",
    "from": {"name": "发件人", "email": "[email protected]"},
    "to": [{"name": "收件人", "email": "[email protected]"}],
    "date": "2024-01-15 10:30:00",
    "body": {
        "plain": "纯文本内容",
        "html": "\x3Chtml>...\x3C/html>"
    },
    "attachments": [
        {"index": 0, "name": "file.pdf", "size": 102400, "type": "application/pdf"}
    ],
    "headers": {"Message-ID": "...", "References": "..."}
}

命令行使用

# 列出收件箱邮件
python -m scripts.email_client --action list --count 10

# 查看邮件详情
python -m scripts.email_client --action show --uid 12345

# 搜索邮件
python -m scripts.email_client --action search --keyword "发票"

# 查看文件夹
python -m scripts.email_client --action folders

# 发送测试邮件
python -m scripts.email_client --action send \
    --to "[email protected]" \
    --subject "测试邮件" \
    --body "这是测试邮件的内容"

# 从 UTF-8 文件读取正文后发送,适合 Windows 下发送中文邮件
python -m scripts.email_client --action send \
    --to "[email protected]" \
    --subject "天气简报" \
    --body-file "./mail_body.txt"

# 发送 HTML 文件内容
python -m scripts.email_client --action send \
    --to "[email protected]" \
    --subject "HTML 邮件" \
    --html-body-file "./mail_body.html"

常见问题

Q: 认证失败怎么办?

A: 请确保:

  1. 邮箱地址正确
  2. 使用的是"应用专用密码"而非登录密码(Gmail/QQ等)
  3. IMAP 和 SMTP 服务已在邮箱设置中开启

Q: 如何处理中文乱码?

A: 脚本已内置编码检测和转换,会自动处理 GBK、UTF-8 等编码。

Q: 附件大小有限制吗?

A: 一般邮箱对附件大小有限制(Gmail 通常 25MB),请确保附件在此范围内。

输出格式示例

========================================
📧 收件箱 - 最新邮件
========================================

[1] 主题: 会议通知
    发件人: [email protected]
    时间: 2024-01-15 10:30:00
    状态: 已读

[2] 主题: 发票报销
    发件人: [email protected]
    时间: 2024-01-15 09:15:00
    状态: 未读 ⭐

========================================
共 2 封邮件
========================================
安全使用建议
This skill appears to implement the advertised IMAP/SMTP email capabilities, but exercise caution before installing. Key points: (1) It expects you to provide EMAIL_ADDRESS, EMAIL_IMAP_PASSWORD and EMAIL_SMTP_PASSWORD in a .env file stored in the skill directory — the registry metadata does NOT declare these secrets, so you might not be warned by the platform. (2) Storing credentials in a skill subfolder is risky (may be committed to source control or readable by other processes); prefer using application-specific passwords and keep .env out of shared repos. (3) The code only uses standard Python libraries and does not contact unknown endpoints, but review scripts/email_client.py yourself to confirm there are no unexpected network targets. (4) If you plan to use this in production, run it in an isolated environment, use app-specific or limited-scope credentials, and consider moving secret storage to a secure secret manager or the platform's recommended secret storage rather than a skill .env file. If you need higher confidence, request the author/source, or ask them to update the registry metadata to declare required credentials and explain how secrets are stored and protected.
功能分析
Type: OpenClaw Skill Name: email-operations Version: 2.0.1 The email-operations skill provides standard IMAP and SMTP functionality for managing emails, as described in SKILL.md. The core logic in scripts/email_client.py uses Python's standard libraries (imaplib, smtplib) to interact with user-configured mail servers and includes features for reading, searching, and sending emails with attachments. No evidence of credential exfiltration, unauthorized network calls, or malicious prompt injection was found.
能力评估
Purpose & Capability
The name/description (email read/send via IMAP/SMTP) matches the included Python code which implements IMAP/SMTP clients. However the registry metadata declares no required environment variables or primary credential while the SKILL.md and code require EMAIL_ADDRESS, EMAIL_IMAP_PASSWORD and EMAIL_SMTP_PASSWORD stored in a .env file. The credentials are relevant to the stated purpose, but the omission from metadata is an incoherence that may mislead users.
Instruction Scope
SKILL.md instructions are narrowly scoped to email operations (reading inbox, searching, fetching details, sending mail, saving attachments). It explicitly instructs users to place credentials in skills/email-operations/.env and demonstrates CLI and API usage. That instruction is within the feature scope but impacts security/usability (see environment_proportionality).
Install Mechanism
No install spec (instruction-only) and the code uses only Python standard libraries. No remote downloads or third-party package installs are required. This is low-risk for installation.
Credentials
The skill requires sensitive credentials (email address and IMAP/SMTP passwords) but the registry metadata does not list required env vars or a primary credential. Instead, SKILL.md instructs storing credentials in a .env file under the skill directory. Storing secrets in a skill subdirectory can be insecure (may be checked into repos or read by other processes). The skill requests separate IMAP and SMTP passwords (reasonable for some providers), but the metadata omission and the recommendation to keep credentials in the skill folder are disproportionate to safe handling expectations.
Persistence & Privilege
always is false and there is no indication the skill modifies other skills or system-wide settings. The skill will read/write files (the skill's .env and downloaded attachments) but does not request permanent platform-wide privileges. Agent autonomous invocation is allowed (default) — since the skill handles sensitive credentials, users should be aware of that.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install email-operations
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /email-operations 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v2.0.1
- 新增详细 SKILL.md 指南,涵盖 SMTP/IMAP 邮箱收发、配置方法、常见邮箱服务示例及功能表 - 明确 `.env` 文件为凭证配置,补充各平台适配参数及注意事项 - 详列所有核心 API 方法、主要数据结构与结果示例 - 增加命令行用法与常见问题解答,便于上手和故障排查
元数据
Slug email-operations
版本 2.0.1
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Email Operations 是什么?

邮件操作技能,通过 SMTP/IMAP 协议读取和发送邮件。当用户想要查看邮件、搜索邮件内容、 获取收件箱列表、拉取特定邮件详情、发送邮件、或需要与邮箱服务交互时,使用此技能。 无论用户是否明确提到 "IMAP" 或 "SMTP",只要涉及邮件收发操作,均可触发此技能。 适用场景:查看收件箱、搜索邮件、按条件过滤... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 133 次。

如何安装 Email Operations?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install email-operations」即可一键安装,无需额外配置。

Email Operations 是免费的吗?

是的,Email Operations 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Email Operations 支持哪些平台?

Email Operations 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Email Operations?

由 yiweiweilai(@yiweiweilai)开发并维护,当前版本 v2.0.1。

💬 留言讨论