Skills imap-idle-watcher
install
source · Clone the upstream repo
git clone https://github.com/openclaw/skills
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/openclaw/skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/axellageraldinc/imap-idle-watcher" ~/.claude/skills/clawdbot-skills-imap-idle-watcher && rm -rf "$T"
manifest:
skills/axellageraldinc/imap-idle-watcher/SKILL.mdsource content
IMAP IDLE Watcher
Real-time email watcher. Uses IMAP IDLE (server push) instead of polling. App passwords instead of OAuth — no token expiry, no re-auth.
Quick Start
Interactive
bash scripts/setup_service.sh
Prompts for email, detects provider, gives app password link, tests connection, installs service.
Non-interactive
bash scripts/setup_service.sh \ --account "user@gmail.com" \ --password "xxxx xxxx xxxx xxxx" \ --command "python3 /path/to/handler.py" \ --service-name my-watcher
Test connection only
bash scripts/setup_service.sh --test --account "user@gmail.com" --password "xxxx"
Configuration (env vars)
| Variable | Default | Description |
|---|---|---|
| (required) | Email address |
| (required) | App password |
| | IMAP server (auto-detected from email) |
| | IMAP port |
| | Folder to watch |
| (optional) | Shell command to run on new mail |
| (optional) | Only trigger for these senders (comma-separated, substring match) |
| (optional) | Only trigger for these subjects (comma-separated, substring match) |
| | Seconds before IDLE renewal (max 1740) |
| | Min seconds between command runs |
Filtering
Only process emails matching specific senders or subjects:
FILTER_FROM=paypal.com,stripe.com # from contains either (OR) FILTER_SUBJECT=payment,invoice # subject contains either (OR)
- Case-insensitive substring match
- Both FROM and SUBJECT must match if both set (AND)
- Within each filter, any value matches (OR)
- No filter set = process all emails
Writing a Handler
The agent should write a handler script based on the user's intent. The daemon passes email metadata as env vars:
| Variable | Example |
|---|---|
| |
| |
| |
| |
Workflow
- User describes what they want (e.g. "watch my inbox, summarize new emails")
- Agent writes a handler script (Python/Bash) that reads the env vars and does what the user asked
- Agent saves it somewhere persistent (e.g.
)~/email-handler.py - Agent runs
withsetup_service.sh--command "python3 ~/email-handler.py"
Example: user says "notify me about new emails"
Agent writes
~/email-handler.py:
#!/usr/bin/env python3 import os print(f"New mail from {os.environ.get('MAIL_FROM', '?')}: {os.environ.get('MAIL_SUBJECT', '?')}")
Then wires it up:
bash scripts/setup_service.sh --account "user@gmail.com" --password "xxxx" \ --command "python3 ~/email-handler.py"
The handler is the agent's job — adapt it to whatever the user needs.
How It Works
- Connects to IMAP server with app password (SSL)
- Enters IDLE mode — server holds connection open
- Server pushes notification when new mail arrives (instant, no polling)
- Daemon runs
with email metadata as env vars (ON_NEW_MAIL_CMD
,MAIL_FROM
,MAIL_SUBJECT
,MAIL_DATE
)MAIL_UID - Returns to IDLE. Renews every 20 min per RFC 2177.
- Auto-reconnects on disconnect (backoff: 5s → 10s → 30s → 60s → 120s)
Service Management
systemctl status <service-name> journalctl -u <service-name> -f systemctl restart <service-name> systemctl stop <service-name>
Uninstall
bash scripts/setup_service.sh --uninstall --service-name <service-name>
Provider Setup Guides
- Gmail: see references/gmail.md
- Outlook: see references/outlook.md
- Yahoo: see references/yahoo.md
Troubleshooting
See references/troubleshooting.md for common errors and fixes.