Email Reporter Skill
Overview
A unified email reporting tool for OpenClaw agents. Automatically converts Markdown reports to PDF when images are detected, and sends them as attachments.
Features
- - Smart Format Detection: Auto-converts to PDF for reports with images or large files (>500KB)
- Markdown Support: Native Markdown rendering with syntax highlighting
- Flexible Configuration: Environment variables or config file for email settings
- Multiple Backends: Support for msmtp, SMTP, and sendmail
Installation
CODEBLOCK0
Configuration
Option 1: Environment Variables (Recommended)
CODEBLOCK1
Option 2: Config File
Create ~/.email_reporter.conf:
CODEBLOCK2
Option 3: Command Line
CODEBLOCK3
Usage
Basic Usage
CODEBLOCK4
In Your Agent
CODEBLOCK5
File Format Selection
| Scenario | Format | Delivery |
|---|
| Plain text (<100KB) | Markdown | Direct |
| With images or >500KB |
PDF | Attachment |
| Data tables | Markdown + CSV | Attachment bundle |
SMTP Setup Guide
QQ Mail (腾讯)
- 1. Enable SMTP: 设置 → 账户 → 开启SMTP服务
- Generate auth code (not your password!)
- Use auth code as INLINECODE1
Gmail
- 1. Enable 2FA
- Generate App Password
- Use app password as INLINECODE2
Outlook/Office 365
CODEBLOCK6
Troubleshooting
Email not sending
CODEBLOCK7
PDF conversion fails
CODEBLOCK8
License
MIT
邮件报告技能
概述
面向OpenClaw代理的统一邮件报告工具。检测到图片时自动将Markdown报告转换为PDF,并以附件形式发送。
功能特性
- - 智能格式检测:包含图片或大文件(>500KB)时自动转换为PDF
- Markdown支持:原生Markdown渲染,支持语法高亮
- 灵活配置:支持环境变量或配置文件设置邮件参数
- 多后端支持:兼容msmtp、SMTP和sendmail
安装
bash
clawhub install email-reporter
配置
方式一:环境变量(推荐)
bash
export EMAIL_SENDER=your-email@qq.com
export EMAIL_RECIPIENT=recipient@example.com
export EMAILSMTPHOST=smtp.qq.com
export EMAILSMTPPORT=587
export EMAILSMTPUSER=your-email@qq.com
export EMAILSMTPPASS=your-auth-code
方式二:配置文件
创建 ~/.email_reporter.conf:
json
{
sender: your-email@qq.com,
recipient: recipient@example.com,
smtp_host: smtp.qq.com,
smtp_port: 587,
smtp_user: your-email@qq.com,
smtp_pass: your-auth-code,
use_msmtp: false
}
方式三:命令行参数
bash
python3 email_reporter.py report.md --sender me@qq.com --to friend@example.com
使用方法
基本用法
bash
发送报告至默认收件人
python3 email_reporter.py report.md
指定代理名称(用于邮件主题)
python3 email_reporter.py report.md --agent my-agent
自定义收件人
python3 email_reporter.py report.md --to friend@example.com
自定义主题
python3 email_reporter.py report.md --subject 我的分析报告
在代理中使用
python
import subprocess
发送报告
subprocess.run([
python3, skills/email-reporter/email_reporter.py,
reports/analysis.md,
--agent, invest-agent,
--to, recipient@example.com
])
文件格式选择
| 场景 | 格式 | 发送方式 |
|---|
| 纯文本(<100KB) | Markdown | 直接发送 |
| 包含图片或>500KB |
PDF | 附件发送 |
| 数据表格 | Markdown + CSV | 附件打包 |
SMTP设置指南
QQ邮箱
- 1. 开启SMTP:设置 → 账户 → 开启SMTP服务
- 生成授权码(非登录密码)
- 将授权码设为 EMAILSMTPPASS
Gmail
- 1. 开启两步验证
- 生成应用专用密码
- 将应用密码设为 EMAILSMTPPASS
Outlook/Office 365
bash
export EMAIL
SMTPHOST=smtp.office365.com
export EMAIL
SMTPPORT=587
故障排除
邮件发送失败
bash
测试SMTP连接
python3 -c
import smtplib
s = smtplib.SMTP(smtp.qq.com, 587)
s.starttls()
s.login(your-email@qq.com, your-auth-code)
print(登录成功)
PDF转换失败
bash
安装依赖
pip install markdown weasyprint
Linux系统(Ubuntu/Debian)
sudo apt-get install libpango-1.0-0 libpangoft2-1.0-0
许可证
MIT