简介
基于 Node.js 的 IMAP 邮件自动化工具,支持 ProtonMail/Gmail 等主流服务,通过加密连接实现邮件检索、管理与自动化工作流,为开发者和效率用户提供安全可控的邮箱集成方案。
原始描述
Read and manage email via IMAP (ProtonMail Bridge, Gmail, etc.). Check for new/unread messages, fetch content, search mailboxes, and mark as read/unread. Works with any IMAP server including ProtonMail Bridge.
中文使用说明 来自收录源
核心用法
IMAP Email Reader 是一款基于 Node.js 的邮件管理技能,通过标准 IMAP 协议与邮件服务器通信。用户可通过命令行工具执行多项操作:check 命令快速检查未读邮件并返回摘要列表;fetch 命令获取指定 UID 的完整邮件内容(包括文本和 HTML);search 命令支持多维度筛选,包括发件人、主题、时间范围、已读状态等;mark-read/mark-unread 可批量标记邮件状态;list-mailboxes 则用于查看账户下的所有文件夹。
配置过程支持快速和手动两种模式。针对 ProtonMail Bridge 用户,提供一键 setup 脚本;其他服务如 Gmail 则需配置环境变量,包括主机地址、端口、凭据及 TLS 设置。该技能特别支持 Cron 集成,可设置定时任务实现自动邮件检查与摘要推送,适合构建"晨间邮件简报"或"紧急邮件提醒"等自动化工作流。
显著优点
协议兼容性强:不仅支持 Gmail、Outlook 等主流邮箱,还特别适配 ProtonMail Bridge,满足隐私敏感用户需求。本地化安全架构:凭证仅存储于本地 .env 文件,不上传至第三方服务器,且已预配置 .gitignore 防止误提交。灵活的搜索能力:支持时间范围(如最近 2 小时、7 天)、发件人、主题等多条件组合搜索,便于快速定位关键邮件。轻量无侵入:仅依赖 imap-simple、mailparser 等成熟开源库,无重型框架,启动迅速。自动化友好:命令行接口设计清晰,返回标准 JSON 格式,便于与 Clawdbot 等自动化平台集成,支持定时任务与消息推送。
潜在缺点与局限性
依赖本地 Bridge:使用 ProtonMail 时必须保持 Bridge 桌面端持续运行,增加了本地资源占用。配置门槛:需要用户理解 IMAP 协议基础概念(如 TLS、STARTTLS、端口区别),对非技术用户不够友好。无写回功能:仅能标记已读/未读状态,不支持发送邮件、移动文件夹、删除邮件等完整邮箱管理功能。错误处理局限:网络超时或认证失败时的错误提示较为技术化,缺乏面向终端用户的友好引导。平台限制:目前仅提供 Node.js 实现,无 Python、Go 等其他语言版本,生态系统相对单一。
适合的目标群体
该技能特别适合开发者与 DevOps 工程师,需要构建邮件自动化工作流或集成邮件通知到 CI/CD 流程;隐私意识强的用户,通过 ProtonMail Bridge 实现端到端加密邮件的自动化处理;效率工具爱好者,希望设置定时任务进行邮件摘要、自动分类或重要邮件筛选;以及小型团队管理员,需要监控特定邮箱(如 support@company.com)并自动分发工单。
使用风险
凭证管理风险:尽管有 .gitignore 保护,用户仍可能误将包含明文密码的 .env 文件提交到公共仓库。传输安全风险:若禁用 TLS 或错误配置端口,密码将以明文传输;虽然支持自签名证书,但禁用 REJECT_UNAUTHORIZED 可能遭受中间人攻击。服务稳定性:依赖第三方 IMAP 服务器可用性,Gmail 等服务商可能随时调整"低安全性应用"策略导致连接中断。资源占用:高频轮询(如每 5 分钟检查一次)可能被邮件服务商限流或封禁 IP。邮件内容安全:获取的邮件内容包含 HTML,调用方需自行处理 XSS 防护,避免恶意邮件脚本执行。
技能正文
name: imap-email description: Read and manage email via IMAP (ProtonMail Bridge, Gmail, etc.). Check for new/unread messages, fetch content, search mailboxes, and mark as read/unread. Works with any IMAP server including ProtonMail Bridge.
IMAP Email Reader
Read, search, and manage email via IMAP protocol. Supports ProtonMail Bridge, Gmail IMAP, and any standard IMAP server.
Quick Start
Check for new emails:
node skills/imap-email/scripts/imap.js check
Fetch specific email:
node skills/imap-email/scripts/imap.js fetch <uid>
Mark as read:
node skills/imap-email/scripts/imap.js mark-read <uid>
Search mailbox:
node skills/imap-email/scripts/imap.js search --from "sender@example.com" --unseen
Configuration
Quick setup (ProtonMail Bridge):
cd skills/imap-email
./setup.sh
The setup helper will prompt for Bridge credentials and test the connection.
Manual setup:
- Copy
.env.exampleto.envin the skill folder - Fill in your IMAP credentials
- The
.envfile is automatically ignored by git
Environment variables:
IMAP_HOST=127.0.0.1 # Server hostname
IMAP_PORT=1143 # Server port
IMAP_USER=your@email.com
IMAP_PASS=your_password
IMAP_TLS=false # Use TLS/SSL connection
IMAP_REJECT_UNAUTHORIZED=false # Set to false for self-signed certs (optional)
IMAP_MAILBOX=INBOX # Default mailbox
⚠️ Security: Never commit your .env file! It's already in .gitignore to prevent accidents.
ProtonMail Bridge setup:
- Install and run ProtonMail Bridge
- Use
127.0.0.1:1143for IMAP - Password is generated by Bridge (not your ProtonMail password)
- TLS: Use
false(Bridge uses STARTTLS) REJECT_UNAUTHORIZED: Set tofalse(Bridge uses self-signed cert)
Gmail IMAP setup:
- Host:
imap.gmail.com - Port:
993 - TLS:
true - Enable "Less secure app access" or use App Password
REJECT_UNAUTHORIZED: Omit or set totrue(default)
Commands
check
Check for unread/new emails in mailbox.
node scripts/imap.js check [--limit 10] [--mailbox INBOX] [--recent 2h]
Options:
--limit <n>: Max results (default: 10)--mailbox <name>: Mailbox to check (default: INBOX)--recent <time>: Only show emails from last X time (e.g., 30m, 2h, 7d)
Returns JSON array of messages with:
- uid, from, subject, date, snippet, flags
fetch
Fetch full email content by UID.
node scripts/imap.js fetch <uid> [--mailbox INBOX]
Returns JSON with full body (text + HTML).
search
Search emails with filters.
node scripts/imap.js search [options]
Options:
--unseen Only unread messages
--seen Only read messages
--from <email> From address contains
--subject <text> Subject contains
--recent <time> From last X time (e.g., 30m, 2h, 7d)
--since <date> After date (YYYY-MM-DD)
--before <date> Before date (YYYY-MM-DD)
--limit <n> Max results (default: 20)
--mailbox <name> Mailbox to search (default: INBOX)
Time format examples:
30m= last 30 minutes2h= last 2 hours7d= last 7 days
mark-read / mark-unread
Mark message(s) as read or unread.
node scripts/imap.js mark-read <uid> [uid2 uid3...]
node scripts/imap.js mark-unread <uid> [uid2 uid3...]
list-mailboxes
List all available mailboxes/folders.
node scripts/imap.js list-mailboxes
Cron Integration
Set up periodic email checking with Clawdbot cron:
# Check email every 15 minutes, deliver to iMessage
clawdbot cron add \
--name "email-check" \
--cron "*/15 * * * *" \
--session isolated \
--message "Check for new ProtonMail emails and summarize them" \
--deliver \
--channel imessage \
--to "+15085600825"
Inside the isolated session, the agent can run:
node /Users/mike/clawd/skills/imap-email/scripts/imap.js check --limit 5
Workflow Examples
Morning email digest:
- Run
check --limit 10 --recent 12h - Summarize unread emails from overnight
- Deliver summary to preferred channel
Check recent emails from specific sender:
- Run
search --from "important@company.com" --recent 24h - Fetch full content if needed
- Mark as read after processing
Hourly urgent email check:
- Run
search --recent 1h --unseen - Filter for important keywords
- Extract action items
- Deliver notification if urgent
Weekly digest:
- Run
search --recent 7d --limit 20 - Summarize activity
- Generate weekly report
Dependencies
Required packages: imap-simple, mailparser, dotenv
Installation:
cd skills/imap-email
npm install
This will install all dependencies listed in package.json.
Security Notes
- Store credentials in
.env(add to.gitignore) - ProtonMail Bridge password is NOT your account password
- Bridge must be running for ProtonMail IMAP access
- Consider using app-specific passwords for Gmail
Troubleshooting
Connection timeout:
- Verify IMAP server is running and accessible
- Check host/port configuration
- Test with:
telnet <host> <port>
Authentication failed:
- Verify username (usually full email address)
- Check password is correct
- For ProtonMail Bridge: use Bridge-generated password, not account password
- For Gmail: use App Password if 2FA is enabled
TLS/SSL errors:
- Match
IMAP_TLSsetting to server requirements (true for SSL, false for STARTTLS) - For self-signed certs (e.g., ProtonMail Bridge): set
IMAP_REJECT_UNAUTHORIZED=false - Check port matches TLS setting (993 for SSL, 143 for STARTTLS)
Empty results:
- Verify mailbox name (case-sensitive)
- Check search criteria
- List mailboxes with
list-mailboxes
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。