本地 AI 驱动的隐私优先邮件管家
简介
基于本地 Ollama LLM 的 IMAP 邮件智能分类工具,支持紧急/待回复/信息/垃圾四级分类,零第三方依赖,为个人和团队提供隐私优先的收件箱自动化管理方案。
原始描述
IMAP email scanning and triage with AI classification via a local Ollama LLM. Scans unread emails, categorizes them as urgent, needs-response, informational,...
通过你的 Agent 添加
安装目录:email-triage/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
中文使用说明 来自收录源
核心用法
Email Triage 是一款面向 IMAP 邮箱的智能分类工具,通过本地部署的 Ollama 大语言模型或启发式规则,自动将未读邮件划分为四个优先级类别:紧急(urgent)、需回复(needs-response)、信息类(informational)和垃圾邮件(spam)。用户通过命令行执行 scan 扫描收件箱、、report 查看待处理邮件、、mark-surfaced 标记已处理,形成完整的邮件处理工作流。工具采用状态持久化机制,通过 JSON 文件跟踪邮件分类历史和已读状态,避免重复处理。
显著优点
隐私优先架构:所有邮件内容仅在本地处理,Ollama 运行在 127.0.0.1,无需将敏感信息上传至云端 API,适合对数据主权要求严格的用户。
零依赖设计:仅使用 Python 标准库(imaplib、urllib、json 等),彻底消除供应链攻击风险,部署简单且长期可维护。
智能降级机制:当 Ollama 不可用时自动切换至关键词启发式分类,确保服务连续性;同时支持只读 IMAP 模式,降低误操作风险。
状态精细化管理:基于 Message-ID 的去重机制、200 条记录的自动修剪、以及 surfaced 标记系统,使工具能够无缝融入自动化工作流(如 cron 定时任务或 Agent 流水线)。
潜在缺点与局限性
分类精度依赖本地算力:7B 参数模型(默认 qwen2.5:7b)对复杂语境的理解有限,可能出现误判;启发式规则对非英语邮件或高度个性化的邮件格式效果欠佳。
IMAP 协议限制:仅支持标准 IMAP 访问,无法处理需要 OAuth2 的现代邮箱(如部分企业 Microsoft 365 配置),且每次扫描最多处理 20 封邮件,大规模收件箱需要频繁轮询。
单用户设计:状态文件为本地 JSON,不支持多设备同步或团队协作场景下的状态共享。
无主动通知能力:工具本身不集成推送或邮件提醒,需要外部系统轮询 report --json 输出才能触发后续动作。
适合的目标群体
- 技术型个人用户:开发者、研究员、自由职业者等需要管理多个邮箱且重视隐私的人群
- 小型团队运维:需要监控基础设施告警邮箱(urgent 类别)的 DevOps 工程师
- 本地优先的自动化工作流:将邮件处理集成到自托管的 Agent 系统或 HomeLab 环境
- 离线或受限网络环境:无法使用云端邮件服务 API 的内网或边缘计算场景
使用风险
凭据管理风险:IMAP 密码需通过环境变量配置,若部署环境日志记录不完善,存在敏感信息泄露可能;建议强制使用应用专用密码并限制环境变量访问权限。
状态文件膨胀:虽然自动修剪至 200 条,但高频扫描场景下 JSON 文件仍可能产生 I/O 瓶颈,建议定期归档或监控磁盘使用。
Ollama 服务可用性:本地 LLM 服务崩溃或模型加载失败将导致分类质量下降,生产环境需配置健康检查和告警。
邮件内容本地存储:分类后的邮件主题、发件人等信息持久化在状态文件中,共享设备或备份场景需注意数据残留风险。
技能正文
name: email-triage
description: IMAP email scanning and triage with AI classification via a local Ollama LLM. Scans unread emails, categorizes them as urgent, needs-response, informational, or spam, and surfaces important messages for agent consumption. Works standalone with heuristic fallback — Ollama optional but recommended.
Email Triage
Scan your IMAP inbox, classify emails into priority categories, and surface the ones that need attention. Uses a local LLM (Ollama) for intelligent classification with a rule-based heuristic fallback when Ollama is unavailable.
Prerequisites
- Python 3.10+
- IMAP-accessible email account (Gmail, Fastmail, self-hosted, etc.)
- Ollama (optional) — for AI-powered classification. Without it, the script uses keyword-based heuristics that still work well for common patterns.
Categories
Icon
Category
Description
🔴
urgent
Outages, security alerts, legal, payment failures, time-critical
🟡
needs-response
Business inquiries, questions, action items requiring a reply
🔵
informational
Receipts, confirmations, newsletters, automated notifications
⚫
spam
Marketing, promotions, unsolicited junk
Configuration
| Icon | Category | Description |
|---|---|---|
| 🔴 | urgent |
Outages, security alerts, legal, payment failures, time-critical |
| 🟡 | needs-response |
Business inquiries, questions, action items requiring a reply |
| 🔵 | informational |
Receipts, confirmations, newsletters, automated notifications |
| ⚫ | spam |
Marketing, promotions, unsolicited junk |
Configuration
All configuration is via environment variables:
| Variable | Required | Default | Description |
|---|---|---|---|
IMAP_HOST |
✅ | — | IMAP server hostname |
IMAP_PORT |
— | 993 |
IMAP port (SSL) |
IMAP_USER |
✅ | — | IMAP username / email address |
IMAP_PASS |
✅ | — | IMAP password or app-specific password |
EMAIL_TRIAGE_STATE |
— | ./data/email-triage.json |
Path to the JSON state file |
OLLAMA_URL |
— | http://127.0.0.1:11434 |
Ollama API endpoint |
OLLAMA_MODEL |
— | qwen2.5:7b |
Ollama model for classification |
Commands
# Scan inbox and classify new unread emails
python3 scripts/email-triage.py scan
# Scan with verbose output (shows each classification)
python3 scripts/email-triage.py scan --verbose
# Dry run — scan and classify but don't save state
python3 scripts/email-triage.py scan --dry-run
# Show unsurfaced important emails (urgent + needs-response)
python3 scripts/email-triage.py report
# Same as report but JSON output (for programmatic use)
python3 scripts/email-triage.py report --json
# Mark reported emails as surfaced (so they don't appear again)
python3 scripts/email-triage.py mark-surfaced
# Show triage statistics
python3 scripts/email-triage.py stats
How It Works
- Connects to IMAP over SSL and fetches unread messages (up to 20 per scan).
- Deduplicates by Message-ID (or a hash of subject + sender as fallback) so emails are never classified twice.
- Classifies each email using Ollama if available, otherwise falls back to keyword heuristics.
- Stores state in a local JSON file — tracks category, reason, and whether the email has been surfaced.
report surfaces only unsurfaced urgent and needs-response emails, sorted by priority.
mark-surfaced flags reported emails so they won't appear in future reports.
- Auto-prunes state to the most recent 200 entries to prevent unbounded growth.
Integration Tips
- Heartbeat / cron: Run
scan periodically, then report --json to check for items needing attention.
- Agent workflow:
scan → report --json → act on results → mark-surfaced.
- Without Ollama: The heuristic classifier handles common patterns (automated notifications, marketing, urgent keywords) well. Ollama adds nuance for ambiguous emails.
- App passwords: If your provider uses 2FA, generate an app-specific password for IMAP access.
# Scan inbox and classify new unread emails
python3 scripts/email-triage.py scan
# Scan with verbose output (shows each classification)
python3 scripts/email-triage.py scan --verbose
# Dry run — scan and classify but don't save state
python3 scripts/email-triage.py scan --dry-run
# Show unsurfaced important emails (urgent + needs-response)
python3 scripts/email-triage.py report
# Same as report but JSON output (for programmatic use)
python3 scripts/email-triage.py report --json
# Mark reported emails as surfaced (so they don't appear again)
python3 scripts/email-triage.py mark-surfaced
# Show triage statistics
python3 scripts/email-triage.py stats
- Connects to IMAP over SSL and fetches unread messages (up to 20 per scan).
- Deduplicates by Message-ID (or a hash of subject + sender as fallback) so emails are never classified twice.
- Classifies each email using Ollama if available, otherwise falls back to keyword heuristics.
- Stores state in a local JSON file — tracks category, reason, and whether the email has been surfaced.
reportsurfaces only unsurfaced urgent and needs-response emails, sorted by priority.mark-surfacedflags reported emails so they won't appear in future reports.- Auto-prunes state to the most recent 200 entries to prevent unbounded growth.
Integration Tips
- Heartbeat / cron: Run
scan periodically, then report --json to check for items needing attention.
- Agent workflow:
scan → report --json → act on results → mark-surfaced.
- Without Ollama: The heuristic classifier handles common patterns (automated notifications, marketing, urgent keywords) well. Ollama adds nuance for ambiguous emails.
- App passwords: If your provider uses 2FA, generate an app-specific password for IMAP access.
scan periodically, then report --json to check for items needing attention.scan → report --json → act on results → mark-surfaced.正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。