QQ邮箱定时监控
让 AI 自动监控邮箱,发现重要邮件时主动推送通知到 QQ。
功能特性
功能 说明
定时检查 每5分钟自动检查一次新邮件
智能过滤 只推送重要邮件(验证码、银行、支付、面试、GitHub 等)
静默模式 无重要邮件时完全不打扰用户
状态跟踪 记录已检查邮件,避免重复通知
多关键词 可自定义重要邮件关键词
快速开始
# 创建配置目录
mkdir -p ~/.openclaw/workspace/email_config
# 创建环境变量文件
cat > ~/.openclaw/workspace/email_config/qqmail_env.sh << 'EOF'
export QQ_EMAIL="your_email@qq.com"
export QQ_EMAIL_PASSWORD="your授权码"
EOF
获取QQ邮箱授权码:
登录 QQ 邮箱 → 设置 → 账户
找到 "POP3/IMAP/SMTP/Exchange/CardDAV/CalDAV 服务"
开启 "IMAP/SMTP 服务"
点击"生成授权码",按提示发送短信获取
# 创建定时任务:每5分钟检查一次
openclaw cron add \
--name "邮箱监控" \
--every "5m" \
--message "执行 ~/.openclaw/workspace/skills/email-monitor/scripts/silent_monitor.sh" \
--session isolated \
--no-deliver
# 查看定时任务
openclaw cron list | grep 邮箱
# 手动运行一次测试
bash ~/.openclaw/workspace/skills/email-monitor/scripts/silent_monitor.sh
使用指南
手动检查邮件
# 静默模式(只推送重要邮件)
bash ~/.openclaw/workspace/skills/email-monitor/scripts/silent_monitor.sh
# 完整模式(每次都输出日志)
bash ~/.openclaw/workspace/skills/email-monitor/scripts/full_monitor.sh
查看监控状态
# 查看状态文件
cat ~/.openclaw/workspace/email_config/silent_monitor_state.json
# 查看监控日志
tail -f ~/.openclaw/workspace/email_logs/realtime_monitor_*.log
停止监控
# 查看任务ID
openclaw cron list | grep 邮箱
# 删除任务
openclaw cron delete <任务ID>
配置说明
修改关键词
编辑 ~/.openclaw/workspace/skills/email-monitor/scripts/silent_monitor.sh 中的 important_keywords 列表:
important_keywords = [
'验证码',
'验证',
'code',
'verify',
'银行',
'支付',
'交易',
'转账',
'账单',
'重要',
'紧急',
'urgent',
'important',
'安全',
'账户',
'登录',
'密码',
'工作',
'面试',
'offer',
'合同',
'github',
'gitlab',
'发票',
'报销',
# 在这里添加你关心的关键词
]
修改通知目标
编辑脚本中的 --to 参数:
# 找到这行,修改为目标用户的 ID
openclaw message send --channel qqbot --to qqbot:c2c:目标用户ID --message "$NOTIFICATION"
通知示例
当发现重要邮件时,发送如下通知:
新邮件通知
========================================
发现 3 封新邮件,其中 2 封重要
重要邮件:
- 您的GitHub账号验证码 (发件人: notifications@github.com)
- 【面试通知】请查收... (发件人: hr@company.com)
时间: 14:30
请及时处理重要邮件
文件结构
email-monitor/
├── SKILL.md # 本文件
├── scripts/
│ ├── silent_monitor.sh # 静默监控脚本(推荐)
│ └── full_monitor.sh # 完整监控脚本
注意事项
首次运行:首次执行会创建状态文件,记录当前邮件ID,不会发送通知
静默逻辑:只有包含关键词的邮件才会推送,普通邮件(如订阅号营销内容)会被忽略
网络问题:任何网络错误都会静默处理,不影响定时任务下次执行
授权码:必须是 QQ 邮箱的授权码,不是登录密码
AI 使用
当用户说以下内容时,使用此 skill:
"检查一下邮箱"
"看看有没有新邮件"
"邮箱有重要邮件吗"
"设置邮箱监控"
"启动邮件通知"