Files
ai-chat-app/skills/email-sender/SKILL.md
hubian 213f898a7c feat: 项目管理机制 + 邮件发送技能 + 心跳任务
新增:
- PROJECTS.md: 项目开发记录文件(简介、启动命令、检查方式)
- email-sender技能: SMTP邮件发送工具
- 心跳任务: 每日对话总结

更新:
- MEMORY.md: 添加自动推送规范
- HEARTBEAT.md: 添加每日总结任务配置
2026-04-09 12:11:59 +08:00

168 lines
3.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
name: email-sender
description: Send emails via SMTP with support for attachments, CC/BCC, HTML content, and multiple SMTP accounts. Use when user wants to send emails through Python/SMTP, configure email settings, or send emails with attachments.
---
# Email Sender / 邮件发送工具
通过 SMTP 发送邮件,支持附件、抄送/密送、HTML 格式和多账号管理。
## 快速开始
### 1. 配置 SMTP
```bash
cd ~/.openclaw/workspace-coder/skills/email-sender/scripts
python3 send_email.py config my-email \
--server mail.tphai.com \
--port 587 \
--email guwen@tphai.com \
--password "your-password" \
--no-tls
```
参数说明:
- `my-email`: 配置名称(可自定义)
- `--server`: SMTP 服务器地址
- `--port`: SMTP 端口
- `--email`: 邮箱地址
- `--password`: 邮箱密码
- `--no-tls`: 不使用 TLS 加密(默认使用 TLS
### 2. 查看配置
```bash
python3 send_email.py list
```
### 3. 发送邮件
**简单邮件:**
```bash
python3 send_email.py send \
--to wlq@tphai.com \
--subject "测试邮件" \
--body "这是一封测试邮件"
```
**带附件的邮件:**
```bash
python3 send_email.py send \
--to wlq@tphai.com \
--subject "带附件的邮件" \
--body "请查收附件" \
--attach /path/to/file1.pdf \
--attach /path/to/file2.jpg
```
**HTML 邮件:**
```bash
python3 send_email.py send \
--to wlq@tphai.com \
--subject "HTML 邮件" \
--body "<h1>标题</h1><p>内容</p>" \
--html
```
**抄送和密送:**
```bash
python3 send_email.py send \
--to wlq@tphai.com \
--cc "cc1@example.com,cc2@example.com" \
--bcc "bcc@example.com" \
--subject "抄送测试" \
--body "这是一封抄送测试邮件"
```
## Python API 使用
```python
from send_email import send_email, setup_account
# 配置 SMTP
setup_account(
name="work",
smtp_server="mail.tphai.com",
smtp_port=587,
email="guwen@tphai.com",
password="your-password",
use_tls=False
)
# 发送简单邮件
send_email(
to="wlq@tphai.com",
subject="测试",
body="内容"
)
# 发送带附件的邮件
send_email(
to="wlq@tphai.com",
subject="附件测试",
body="请查收附件",
attachments=["/path/to/file.pdf", "/path/to/image.jpg"],
verbose=True
)
# 发送 HTML 邮件
send_email(
to="wlq@tphai.com",
subject="HTML 测试",
body="<h1>Hello</h1><p>World</p>",
html=True
)
# 使用特定账号
send_email(
to="wlq@tphai.com",
subject="使用指定账号",
body="内容",
account_name="work"
)
```
## 配置文件
配置保存在 `scripts/smtp_config.json` 中:
```json
{
"accounts": [
{
"name": "my-email",
"smtp_server": "mail.tphai.com",
"smtp_port": 587,
"email": "guwen@tphai.com",
"password": "your-password",
"use_tls": false
}
]
}
```
## 常用 SMTP 设置
| 服务商 | SMTP 服务器 | 端口 | TLS |
|--------|-------------|------|-----|
| Gmail | smtp.gmail.com | 587 | 是 |
| Outlook | smtp.office365.com | 587 | 是 |
| QQ邮箱 | smtp.qq.com | 587 | 是 |
| 163邮箱 | smtp.163.com | 465 | 是 |
| 企业邮箱 | mail.tphai.com | 587 | 否 |
## 故障排除
**认证失败:**
- 检查邮箱密码是否正确
- Gmail 需要使用「应用专用密码」而非登录密码
- QQ邮箱需要使用授权码而非登录密码
**连接失败:**
- 检查 SMTP 服务器地址和端口
- 检查防火墙设置
- 尝试切换 TLS/SSL 模式
**邮件被退回:**
- 检查收件人地址是否正确
- 检查邮件头是否完整(本工具自动添加 Date 和 Message-Id