← 返回 Skills 市场
polumish

Imap Mail

作者 Sergey · GitHub ↗ · v1.5.4
cross-platform ⚠ suspicious
589
总下载
0
收藏
8
当前安装
20
版本数
在 OpenClaw 中安装
/install imap-mail
功能描述
Personal email via your own IMAP/SMTP server. Send and receive emails, manage folders, and search messages using standard protocols — no third-party email pl...
使用说明 (SKILL.md)

IMAP Mail Skill

Send and receive email through your own IMAP/SMTP server.

A lightweight local REST API (FastAPI) runs as a bridge between the agent and your mail server — no third-party email platform needed.

Setup (first time)

1. Install dependencies

pip3 install fastapi uvicorn

2. Configure credentials

Create /etc/imap-mail.env (or any path, then set IMAP_MAIL_ENV):

MAIL_IMAP_HOST=mail.example.com
MAIL_IMAP_PORT=993
MAIL_SMTP_HOST=mail.example.com
MAIL_SMTP_PORT=465
[email protected]
MAIL_PASS=yourpassword
MAIL_FROM_NAME=MyAgent

3. Start the API server

# One-time / foreground
python3 {baseDir}/scripts/mail-api.py

# Or as a systemd service (recommended)
# See: {baseDir}/references/systemd.md

The API listens on http://127.0.0.1:8025 by default.

Checking Email

# List recent messages
python3 {baseDir}/scripts/check_inbox.py --inbox [email protected]

# Unread only
python3 {baseDir}/scripts/check_inbox.py --inbox [email protected] --unseen

# Specific folder
python3 {baseDir}/scripts/check_inbox.py --inbox [email protected] --folder Sent

# Read a specific message (use UID from list output)
python3 {baseDir}/scripts/check_inbox.py --inbox [email protected] --message 42

# Read message and save all its attachments
python3 {baseDir}/scripts/check_inbox.py --inbox [email protected] --message 42 --save-attachments /tmp/mail/

# List threads
python3 {baseDir}/scripts/check_inbox.py --inbox [email protected] --threads

# List all folders
python3 {baseDir}/scripts/check_inbox.py --inbox [email protected] --folders

Searching Email

# Search by keyword (subject + body)
python3 {baseDir}/scripts/search.py --inbox [email protected] --q "invoice"

# Search by sender
python3 {baseDir}/scripts/search.py --inbox [email protected] --from "[email protected]"

# Search by subject + date range
python3 {baseDir}/scripts/search.py --inbox [email protected] --subject "meeting" --since 2026-01-01

# Find unread messages
python3 {baseDir}/scripts/search.py --inbox [email protected] --unseen

# Find messages with attachments and save them
python3 {baseDir}/scripts/search.py --inbox [email protected] --has-attachments --save-attachments /tmp/mail/

# Find messages from VIP senders only
python3 {baseDir}/scripts/search.py --inbox [email protected] --vip

# Find only flagged/starred messages
python3 {baseDir}/scripts/search.py --inbox [email protected] --flagged

# Find flagged messages from a specific sender
python3 {baseDir}/scripts/search.py --inbox [email protected] --from "[email protected]" --flagged

# Combined filters: unread messages from a specific sender since a date
python3 {baseDir}/scripts/search.py --inbox [email protected] --from "[email protected]" --since 2026-03-01 --unseen

# Unread messages with a specific subject keyword
python3 {baseDir}/scripts/search.py --inbox [email protected] --subject "invoice" --unseen

# Search in a specific folder
python3 {baseDir}/scripts/search.py --inbox [email protected] --q "report" --folder Archive

Sorting Inbox (Personal vs Forwarded)

Automatically move messages into sub-folders based on addressing:

  • Personal — inbox address is directly in To: or Cc:
  • Forwarded — subject starts with Fwd: / FW:, or X-Forwarded-* / Resent-* headers present
  • Forwarded takes priority over Personal when both apply
# Preview what would be moved (no changes)
python3 {baseDir}/scripts/sort_inbox.py --inbox [email protected] --dry-run

# Sort all messages
python3 {baseDir}/scripts/sort_inbox.py --inbox [email protected]

# Sort only unread messages
python3 {baseDir}/scripts/sort_inbox.py --inbox [email protected] --unseen

# Custom folder names
python3 {baseDir}/scripts/sort_inbox.py --inbox [email protected] \
  --personal-folder MyInbox --forwarded-folder Forwards

# Sort a specific source folder
python3 {baseDir}/scripts/sort_inbox.py --inbox [email protected] --folder AllMail

Messages that match neither category (e.g. BCC, bulk mail) stay in the source folder.


Folder Management

# List all folders
python3 {baseDir}/scripts/manage_folders.py --inbox [email protected] --list

# Create a folder
python3 {baseDir}/scripts/manage_folders.py --inbox [email protected] --create Archive

# Delete a folder
python3 {baseDir}/scripts/manage_folders.py --inbox [email protected] --delete OldFolder

# Move a message to another folder (use UID from check_inbox output)
python3 {baseDir}/scripts/manage_folders.py --inbox [email protected] --move 42 --to Archive

# Move from a specific source folder
python3 {baseDir}/scripts/manage_folders.py --inbox [email protected] --move 5 --to INBOX --from-folder Junk

# Delete a message
python3 {baseDir}/scripts/manage_folders.py --inbox [email protected] --delete-msg 42

# Mark all messages in INBOX as read
python3 {baseDir}/scripts/manage_folders.py --inbox [email protected] --mark-seen

# Mark all messages in a specific folder as read
python3 {baseDir}/scripts/manage_folders.py --inbox [email protected] --mark-seen --from-folder Sent

# Mark one specific message as read (use UID from check_inbox output)
python3 {baseDir}/scripts/manage_folders.py --inbox [email protected] --mark-seen-uid 42

# Mark several specific messages as read (space-separated UIDs)
python3 {baseDir}/scripts/manage_folders.py --inbox [email protected] --mark-seen-uid 42 55 73

# Flag (star) specific messages as important
python3 {baseDir}/scripts/manage_folders.py --inbox [email protected] --flag-uid 42 55 73

# Flag ALL messages from a specific sender
python3 {baseDir}/scripts/manage_folders.py --inbox [email protected] --flag-from "[email protected]"
python3 {baseDir}/scripts/manage_folders.py --inbox [email protected] --flag-from "[email protected]"

# Remove flag from messages
python3 {baseDir}/scripts/manage_folders.py --inbox [email protected] --unflag-uid 42
python3 {baseDir}/scripts/manage_folders.py --inbox [email protected] --unflag-from "[email protected]"

Sending Email

# Send a plain text email
python3 {baseDir}/scripts/send_email.py \
  --to [email protected] \
  --subject "Hello" \
  --text "Message body here"

# Send to multiple recipients
python3 {baseDir}/scripts/send_email.py \
  --to [email protected] \
  --to [email protected] \
  --subject "Hello everyone" \
  --text "Hi all!"

# Reply to a message (preserves thread)
python3 {baseDir}/scripts/send_email.py \
  --to [email protected] \
  --subject "Re: Original Subject" \
  --text "My reply" \
  --reply-to "\x3Coriginal-message-id>"

Contact Memory (CRM)

Persistent notes and history per contact. Flagged senders are automatically tracked — when their message arrives, the agent pulls full context and reports in detail.

# Look up everything about a contact
python3 {baseDir}/scripts/manage_contacts.py --get [email protected]

# List all contacts
python3 {baseDir}/scripts/manage_contacts.py --list

# Save a contact with name and tags
python3 {baseDir}/scripts/manage_contacts.py --save [email protected] --name "Craig Smith" --tags "client,priority"

# Append a timestamped note (agent does this automatically after each flagged message)
python3 {baseDir}/scripts/manage_contacts.py --note [email protected] "Wants proposal by Friday. Budget ~$5k."

# Delete a contact
python3 {baseDir}/scripts/manage_contacts.py --delete [email protected]

How it works with flagged mail:

  1. Flagged (starred) UNSEEN messages are processed separately from regular mail
  2. For each flagged message, the agent fetches the sender's full contact history
  3. Reports to user with: who wrote, what they want, full context from previous interactions
  4. Automatically saves a note summarizing the new message

Auto-Rules (persistent flag/action on incoming mail)

Rules are defined once and applied automatically to every new (UNSEEN) message on each mail check — until you remove them.

# Flag ALL future messages from Craig as important (persists forever)
python3 {baseDir}/scripts/manage_rules.py --inbox [email protected] --add --from "[email protected]"

# Flag messages with "URGENT" in subject
python3 {baseDir}/scripts/manage_rules.py --inbox [email protected] --add --subject "URGENT"

# Auto-mark-as-read messages from a newsletter
python3 {baseDir}/scripts/manage_rules.py --inbox [email protected] --add --from "[email protected]" --action mark-seen

# List all active rules
python3 {baseDir}/scripts/manage_rules.py --inbox [email protected] --list

# Apply all rules right now (without waiting for next cron)
python3 {baseDir}/scripts/manage_rules.py --inbox [email protected] --apply

# Temporarily disable a rule (ID from --list)
python3 {baseDir}/scripts/manage_rules.py --inbox [email protected] --disable 1

# Re-enable
python3 {baseDir}/scripts/manage_rules.py --inbox [email protected] --enable 1

# Remove permanently
python3 {baseDir}/scripts/manage_rules.py --inbox [email protected] --remove 1

Scheduled Send

Queue emails for future delivery. The API background scheduler checks every 60 seconds.

# Schedule via API directly (ISO datetime, UTC recommended)
# POST /inboxes/{inbox}/scheduled
# Body: {"to": ["[email protected]"], "subject": "...", "text": "...", "send_at": "2026-03-10T09:00:00Z"}

# List all scheduled messages
# GET /inboxes/{inbox}/scheduled

# Cancel a scheduled message
# DELETE /inboxes/{inbox}/scheduled/{id}

IMAP IDLE (Push Notifications)

Instead of polling every N minutes, IDLE keeps a persistent connection open so the server pushes notifications immediately when new mail arrives.

Add to your env file:

# Required: webhook URL to POST new mail events to
MAIL_IDLE_WEBHOOK=http://127.0.0.1:8080/mail-event

# Optional: folder to watch (default: INBOX)
MAIL_IDLE_FOLDER=INBOX

When new mail arrives, the API POSTs to the webhook:

{
  "event": "new_mail",
  "uid": "123",
  "subject": "Hello",
  "from_": [{"name": "Alice", "email": "[email protected]"}],
  "vip": false,
  ...full message fields...
}

Check IDLE status:

# GET http://127.0.0.1:8025/idle/status

VIP Sender List

Mark specific senders as VIP — their messages will have "vip": true in the API response and in IDLE webhook payloads, enabling urgent/priority handling.

Add to your env file:

[email protected],[email protected]

Messages from VIP senders are flagged in all responses ("vip": true) and can be filtered:

# Show only VIP messages
python3 {baseDir}/scripts/search.py --inbox [email protected] --vip

API Endpoints

The local REST API at http://127.0.0.1:8025 exposes:

Method Path Description
GET /health Check API status (includes IDLE state, VIP list)
GET /idle/status IMAP IDLE watcher status
GET /inboxes/{inbox}/folders List folders
POST /inboxes/{inbox}/folders Create folder
DELETE /inboxes/{inbox}/folders/{name} Delete folder
GET /inboxes/{inbox}/messages List messages (?folder=INBOX&limit=N&unseen=true)
GET /inboxes/{inbox}/messages/{uid} Get full message (?folder=INBOX)
GET /inboxes/{inbox}/messages/{uid}/attachments/{index} Download attachment (base64)
POST /inboxes/{inbox}/messages Send email
POST /inboxes/{inbox}/messages/{uid}/move Move message (?folder=src)
DELETE /inboxes/{inbox}/messages/{uid} Delete message
POST /inboxes/{inbox}/sort Sort into Personal/Forwarded folders (?dry_run=true)
GET /inboxes/{inbox}/search Search (?q=&from=&subject=&since=&vip_only=true)
GET /inboxes/{inbox}/threads List threads
POST /inboxes/{inbox}/scheduled Schedule email for future delivery
GET /inboxes/{inbox}/scheduled List scheduled messages
DELETE /inboxes/{inbox}/scheduled/{id} Cancel scheduled message

Environment Variables

Variable Default Description
MAIL_IMAP_HOST IMAP server hostname
MAIL_IMAP_PORT 993 IMAP port (TLS)
MAIL_SMTP_HOST SMTP server hostname
MAIL_SMTP_PORT 465 SMTP port (TLS)
MAIL_USER Email login / address
MAIL_PASS Password
MAIL_FROM_NAME Agent Display name in From header
MAIL_IDLE_WEBHOOK Webhook URL for IMAP IDLE push events
MAIL_IDLE_FOLDER INBOX Folder to watch with IDLE
MAIL_VIP_SENDERS Comma-separated VIP email addresses
MAIL_SCHEDULED_DB /tmp/imap-mail-scheduled.db SQLite path for scheduled sends
MAIL_ALLOW_SELF_SIGNED false Set true to skip TLS cert verification (self-signed certs)
IMAP_MAIL_API http://127.0.0.1:8025 API base URL (for scripts)
IMAP_MAIL_ENV /etc/imap-mail.env Path to env file
IMAP_MAIL_PORT 8025 API listen port

Security Notes

  • Credentials — mail login and password are stored in a local env file (e.g. /etc/imap-mail.env), readable only by the service user. Never hardcode credentials in scripts.
  • SSL/TLS — all IMAP and SMTP connections use TLS by default. Certificate verification is enabled by default (ssl.create_default_context()). Set MAIL_ALLOW_SELF_SIGNED=true only if your mail server uses a self-signed certificate and you accept the risk.
  • Local API only — the REST bridge listens on 127.0.0.1 (loopback) only and is not exposed to the network.
  • Webhook (IDLE) — if MAIL_IDLE_WEBHOOK is set, full message contents (including body) are POSTed to that URL on new mail. Ensure the webhook URL is a trusted local endpoint.

Compatibility

Works with any standard IMAP/SMTP server:

  • Self-hosted: Dovecot, Postfix, Exim, Maddy
  • Hosted: Gmail (App Password), Outlook/Hotmail, Yahoo Mail, Fastmail, ProtonMail Bridge, and any provider that supports IMAP

Note: Self-signed TLS certificates are accepted automatically.

References

安全使用建议
What to consider before installing: - This package actually contains runnable Python code (a local FastAPI server) and CLI scripts — it's not a pure documentation-only skill. The registry metadata omitted the fact that you must provide mailbox credentials and create an env file (default: /etc/imap-mail.env). Treat MAIL_USER and MAIL_PASS as sensitive: store them with tight file permissions (chmod 600) and preferably run the service under a dedicated unprivileged user. - The service listens on 127.0.0.1 by default (good), but it supports a configurable MAIL_IDLE_WEBHOOK. If you set that to an external URL, new-message events (and possibly message metadata) will be POSTed there — this can leak data if you point it at an untrusted endpoint. If you don't need webhooks leave it unset. - The package instructs installing dependencies via pip (fastapi, uvicorn). Only install these from trusted sources and consider using a virtualenv. Review the included scripts (mail-api.py and helpers) yourself — they are present in the bundle and will run locally. - The SKILL.md shows steps to create and enable a systemd service; enabling a systemd unit requires root and makes the agent persistent. If you decide to run it as a service, create a dedicated system user, restrict filesystem and network permissions, and verify the ExecStart path. - Packaging inconsistencies: registry metadata not declaring required envs/config paths and duplicated files (scripts/scripts/) suggest sloppy packaging. If you plan to use this, inspect the code for any unexpected network calls (especially webhook behavior), or run the service in a confined environment (container or VM) until you are comfortable. - If you want help: I can (a) point out exact lines where webhooks are invoked/constructed in mail-api.py, (b) give step-by-step hardening advice for running the service under a non-root user, or (c) produce a checklist for safely installing/testing this skill in a sandboxed environment.
功能分析
Type: OpenClaw Skill Name: imap-mail Version: 1.5.4 The imap-mail skill bundle provides a legitimate and comprehensive local REST API bridge (FastAPI) for managing email via standard IMAP and SMTP protocols. The core logic in `mail-api.py` facilitates message retrieval, searching, and sending, while supplementary scripts like `manage_rules.py` and `manage_contacts.py` offer advanced features like automated message flagging and contact history tracking. While the skill handles sensitive email credentials and includes a webhook feature for push notifications (IMAP IDLE), these capabilities are clearly aligned with its stated purpose, are restricted to local or user-configured endpoints, and are accompanied by appropriate security documentation in `SKILL.md` and `api.md`.
能力评估
Purpose & Capability
The name/description (IMAP/SMTP mail bridge) matches the included code: a local FastAPI-based API (mail-api.py) plus CLI helpers to list/search/move/send messages. Requiring python3 and FastAPI/uvicorn is appropriate. However the registry metadata declared no required environment variables or config paths despite the runtime instructions and code requiring MAIL_IMAP_HOST, MAIL_USER, MAIL_PASS and an env file (default /etc/imap-mail.env). That omission is an inconsistency in the package metadata.
Instruction Scope
SKILL.md and scripts instruct creating /etc/imap-mail.env and a systemd unit, and starting a long-running local API server. The server supports an IDLE webhook (MAIL_IDLE_WEBHOOK) which — if set to an external URL — will cause the service to POST events off-host (potential data exfiltration if misconfigured). The scripts also perform filesystem writes (saving attachments) and can be run as a system service; these are within a mail-bridge's purpose but are system-level operations that were not declared in the registry metadata and could expose secrets if misconfigured.
Install Mechanism
The registry lists no install spec even though code is included. SKILL.md instructs using pip3 install fastapi uvicorn (packages on PyPI) — a standard but moderately privileged install action. The included code will be executed locally; there is no automated packaged install, so users must run pip and start the server themselves. This is common for Python projects but increases reliance on the user to follow safe installation steps.
Credentials
The skill needs highly sensitive credentials (MAIL_USER, MAIL_PASS, MAIL_IMAP_HOST, MAIL_SMTP_HOST/PORT) and suggests storing them in /etc/imap-mail.env. The registry metadata incorrectly reports no required envs/config paths. The presence of MAIL_IDLE_WEBHOOK (which can send message events to an arbitrary URL) and the suggestion to run as a systemd service (EnvironmentFile=/etc/imap-mail.env) means sensitive secrets will be stored system-wide — this is proportionate to an email bridge but should have been declared and documented more clearly before install.
Persistence & Privilege
The skill provides instructions to install a systemd unit and run a persistent service (imap-mail-api.service) that will read /etc/imap-mail.env. It does not set always:true, but enabling the provided systemd unit requires elevated privileges (root) and grants the service persistent presence. This is not necessarily malicious but is a meaningful privilege and should be treated cautiously (run under a dedicated low-privilege user, restrict env file permissions, bind to localhost only).
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install imap-mail
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /imap-mail 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.5.4
Fix silent output when --unseen finds no messages: cron jobs no longer print "No unread messages" noise. Added --quiet flag for explicit suppression.
v1.5.3
Update skill description to cover all features: auto-rules, VIP senders, CRM contacts, sort inbox (Personal/Forwarded), group inbox (sender/subject clustering), threads, scheduled send, IMAP IDLE webhook, folder management.
v1.5.2
- Added nine new scripts for email management, including inbox checking, sending emails, folder management, searching, sorting, contact management, and rules management. - Introduced standalone scripts for common email operations such as check_inbox.py, search.py, send_email.py, and sort_inbox.py. - Expanded skill functionality to support direct script execution for inbox, contacts, folders, rules, and more. - No changes to API, configuration, or dependencies.
v1.5.1
v1.5.1: Security metadata — declare all required env vars (MAIL_PASS marked secret), pin dependency versions, add chmod 600 and app-specific password guidance, clarify webhook security
v1.5.0
v1.5.0: Group inbox by sender/subject — suggest and auto-apply folder grouping with persistent rules (group_inbox.py)
v1.4.0
Sort inbox into Personal and Forwarded folders. Auto-detects forwards by subject prefix (Fwd:/FW:/Переслано:) or headers. New: sort_inbox.py script, POST /inboxes/{inbox}/sort endpoint with dry-run support
v1.3.0
Simplify cron message to fix isolated session errors; remove placeholder syntax that caused access errors; improve reliability of automated mail checks
v1.2.9
Add contact memory (CRM): per-sender notes/history, priority reporting for flagged senders with full context
v1.2.8
Add persistent auto-rules: auto-flag/mark-seen on incoming mail by sender/subject, manage_rules.py script, cron now applies rules before each check
v1.2.7
Security: SSL verification enabled by default; MAIL_ALLOW_SELF_SIGNED=true opt-in for self-signed certs; document security requirements in SKILL.md
v1.2.6
Add flag/unflag support: flag by UID or by sender address, search --flagged filter
v1.2.5
Fix: use uid STORE for specific UIDs in mark-seen; restart gateway to pick up --unseen cron change
v1.2.4
Cron now checks --unseen only; add combined filter examples to SKILL.md
v1.2.3
Allow marking multiple specific messages as read: --mark-seen-uid 42 55 73
v1.2.2
Fix: document --mark-seen and --mark-seen-uid in SKILL.md
v1.2.1
Add mark-as-read: POST /mark-seen endpoint and --mark-seen / --mark-seen-uid flags in manage_folders.py
v1.2.0
v1.2.0: IMAP IDLE push notifications, VIP sender list, scheduled send (SQLite), attachment download endpoint, --save-attachments flag for check_inbox and search scripts
v1.1.1
Fix: replace curl examples with manage_folders.py script — avoids model confusion when resolving {baseDir}; add --list/--create/--delete/--move/--delete-msg commands
v1.1.0
Add folder management (list/create/delete/move), advanced search (by sender, subject, body, date, unseen, attachments), --folder and --unseen flags, new search.py script
v1.0.0
Initial release — personal IMAP/SMTP bridge for AI agents
元数据
Slug imap-mail
版本 1.5.4
许可证
累计安装 8
当前安装数 8
历史版本数 20
常见问题

Imap Mail 是什么?

Personal email via your own IMAP/SMTP server. Send and receive emails, manage folders, and search messages using standard protocols — no third-party email pl... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 589 次。

如何安装 Imap Mail?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install imap-mail」即可一键安装,无需额外配置。

Imap Mail 是免费的吗?

是的,Imap Mail 完全免费(开源免费),可自由下载、安装和使用。

Imap Mail 支持哪些平台?

Imap Mail 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Imap Mail?

由 Sergey(@polumish)开发并维护,当前版本 v1.5.4。

💬 留言讨论