← 返回 Skills 市场
mohamed-hammane

IMAP SMTP Email

作者 Umbra · GitHub ↗ · v1.0.4 · MIT-0
cross-platform ⚠ suspicious
159
总下载
0
收藏
0
当前安装
5
版本数
在 OpenClaw 中安装
/install imap-smtp-mail
功能描述
Read and send email via IMAP/SMTP using local Node scripts. Use when the agent needs to check inboxes, fetch email content, search messages, download attachm...
使用说明 (SKILL.md)

IMAP/SMTP Email Tool

Use local Node scripts for inbox access and outbound mail:

  • node scripts/imap.js ...
  • node scripts/smtp.js ...

Published as imap-smtp-mail on ClawHub.

Configuration

Create ~/.openclaw/credentials/imap-smtp-mail.env with:

# IMAP
IMAP_HOST=imap.example.com
IMAP_PORT=993
[email protected]
IMAP_PASS=your_password
IMAP_TLS=true
IMAP_REJECT_UNAUTHORIZED=true
IMAP_MAILBOX=INBOX
IMAP_SAVE_SENT=true
# Optional override if your provider does not expose the Sent folder cleanly
# IMAP_SENT_MAILBOX=Sent

# SMTP
SMTP_HOST=smtp.example.com
SMTP_PORT=587
SMTP_SECURE=false
[email protected]
SMTP_PASS=your_password
[email protected]
SMTP_FROM_NAME=Your Name
[email protected]
SMTP_CLIENT_NAME=example.com
SMTP_REJECT_UNAUTHORIZED=true

# File access controls
ALLOWED_READ_DIRS=~/.openclaw/workspace,~/.openclaw/workspace/exports,~/.openclaw/workspace/out,~/.openclaw/workspace/tmp
ALLOWED_WRITE_DIRS=~/.openclaw/workspace/exports,~/.openclaw/workspace/tmp

This skill loads ~/.openclaw/credentials/imap-smtp-mail.env at runtime with dotenv. The credential file path can be overridden with the EMAIL_ENV_FILE environment variable. The IMAP/SMTP variables do not need to be exported globally in the OpenClaw service environment.

SMTP notes:

  • SMTP_FROM_NAME sets a display name.
  • SMTP_REPLY_TO is optional.
  • SMTP_CLIENT_NAME controls the hostname used in EHLO/HELO. If omitted, the script derives it from the sender domain.
  • When only plain text is provided, the tool also generates a simple HTML alternative part.
  • For emails containing structured data, prefer well-formed HTML content over plain-text pseudo-layouts when readability matters.

IMAP Sent-copy notes:

  • If IMAP is configured and IMAP_SAVE_SENT is not false, the tool appends a copy of each sent email to the IMAP Sent mailbox after successful SMTP delivery.
  • The script tries to detect the Sent mailbox automatically using IMAP mailbox attributes and common folder names.
  • If needed, set IMAP_SENT_MAILBOX explicitly (for example Sent, Sent Items, or INBOX.Sent).

Default contact file: contacts/email-contacts.json

Contact shape:

{
  "version": 1,
  "contacts": [
    {
      "id": "client-a",
      "name": "Client A",
      "email": "[email protected]",
      "phone": "+000000000000",
      "aliases": ["client a", "achat client a"],
      "tags": ["client"],
      "notes": "Optional note"
    }
  ]
}

Install

Run once in the skill folder:

cd skills/imap-smtp-mail
npm install

Common commands

Check inbox

cd skills/imap-smtp-mail
node scripts/imap.js check --limit 10

Search email

cd skills/imap-smtp-mail
node scripts/imap.js search --subject "invoice" --recent 7d --limit 20

Fetch one message

cd skills/imap-smtp-mail
node scripts/imap.js fetch 123

Fetch output includes parsed recipient fields (from, to, cc, replyTo) and threading headers (messageId, inReplyTo, references).

Fetch message and read attachment content inline

cd skills/imap-smtp-mail
node scripts/imap.js fetch 123 --extract-attachments

Parses .xlsx, .csv, and .pdf attachments directly and returns their content in the JSON output. Each attachment entry includes a status field:

  • parsed — content extracted. Excel/CSV: sheets[] with headers and rows. PDF: text and pages.
  • skipped_large — over limit: raw file > 500 KB, or Excel > 200 rows / 10 000 cells, or PDF > 25 000 extracted chars. Includes a reason field.
  • skipped_inline_image — image with inline disposition (logo, signature). Silently ignored.
  • unsupported — file type not supported for extraction (e.g. attached JPEG, DOCX, ZIP).
  • failed — parsing error. Includes a reason field.

Additional fields on parsed PDF results:

  • warning: 'scanned_pdf_likely' — extracted text is under 20 chars despite the file having pages; the PDF is probably a scan and text extraction yielded nothing useful.

For multi-sheet workbooks, each sheet carries its own status. The attachment-level status is parsed if at least one sheet was successfully read; skipped_large if all sheets exceeded the limit.

Use fetch --extract-attachments when the email is known or suspected to contain a useful business document (price list, invoice, order). Use the standard download command instead when the file is too large or needs to be saved to disk.

Download attachments

cd skills/imap-smtp-mail
node scripts/imap.js download 123 --dir ~/.openclaw/workspace/tmp

Mark messages as read

cd skills/imap-smtp-mail
node scripts/imap.js mark-read 123 456

Mark messages as unread

cd skills/imap-smtp-mail
node scripts/imap.js mark-unread 123

List mailboxes

cd skills/imap-smtp-mail
node scripts/imap.js list-mailboxes

Test SMTP

Note: This command sends a real test email to your own address (SMTP_USER). It is not a passive connectivity check.

cd skills/imap-smtp-mail
node scripts/smtp.js test

Verbose SMTP debug:

cd skills/imap-smtp-mail
node scripts/smtp.js test --debug

List contacts

cd skills/imap-smtp-mail
node scripts/smtp.js contacts
node scripts/smtp.js contacts --query compta

Resolve one contact

cd skills/imap-smtp-mail
node scripts/smtp.js resolve-contact --contact "Client A"

Send email

cd skills/imap-smtp-mail
node scripts/smtp.js send --to [email protected] --subject "Subject" --body "Message"

By default, send creates a draft preview only. Actual sending requires --approve.

cd skills/imap-smtp-mail
node scripts/smtp.js send --to [email protected] --subject "Subject" --body "Message" --approve

Reply to an existing email

Preview a threaded reply to the sender (or Reply-To when present):

cd skills/imap-smtp-mail
node scripts/smtp.js send --reply-uid 123 --body "Hello,\
\
Received, thanks.\
\
Best regards"

Reply-all while keeping the original To and Cc recipients (except own mailbox and duplicates):

cd skills/imap-smtp-mail
node scripts/smtp.js send --reply-uid 123 --reply-all --body "Hello,\
\
Received, thanks.\
\
Best regards" --approve

With --reply-uid, the tool auto-fills the reply target, adds Re: to the subject when needed, and sets In-Reply-To / References for proper threading. Use --reply-all by default for normal business thread replies unless the user explicitly wants a sender-only reply.

Send email by contact name

cd skills/imap-smtp-mail
node scripts/smtp.js send --contact "Client A" --subject "Subject" --body "Message" --approve

Verbose send debug:

cd skills/imap-smtp-mail
node scripts/smtp.js send --contact "Client A" --subject "Subject" --body "Message" --approve --debug

When IMAP Sent-copy is active, the send result also includes:

  • savedToSent
  • sentMailbox
  • sentCopyError if the SMTP send succeeded but the IMAP append failed

Draft email with attachment

cd skills/imap-smtp-mail
node scripts/smtp.js send --to [email protected] --subject "Report" --body "Please find attached the report." --attach ~/.openclaw/workspace/exports/pdfs/report.pdf

Actual sending with attachment:

cd skills/imap-smtp-mail
node scripts/smtp.js send --to [email protected] --subject "Report" --body "Please find attached the report." --attach ~/.openclaw/workspace/exports/pdfs/report.pdf --approve

Send styled HTML email

cd skills/imap-smtp-mail
node scripts/smtp.js send --to [email protected] --subject "Stock status" --html "\x3Cp>Hello,\x3C/p>\x3Cp>Here is the stock status.\x3C/p>\x3Ctable border=\"1\" cellpadding=\"6\" cellspacing=\"0\">\x3Ctr>\x3Cth>Reference\x3C/th>\x3Cth>Stock\x3C/th>\x3C/tr>\x3Ctr>\x3Ctd>REF-001\x3C/td>\x3Ctd>12\x3C/td>\x3C/tr>\x3C/table>\x3Cp>Best regards\x3C/p>" --approve

Operational rules

  • Use this skill for email only.
  • Keep outbound email approval-based: never auto-send without user validation.
  • Use attachments only from allowed workspace directories.
  • Use contact aliases from contacts/email-contacts.json when the user refers to recipients by name.
  • The contact list is for outbound convenience and recipient resolution; incoming email can come from any sender.
  • The agent may summarize incoming email and prepare a draft reply, but must never auto-reply without user validation.
  • For replies to an inbound email, prefer node scripts/smtp.js send --reply-uid \x3Cuid> --reply-all ...; omit --reply-all only when the user explicitly wants sender-only.
  • node scripts/imap.js fetch \x3Cuid> exposes Cc, Reply-To, messageId, In-Reply-To, and References so reply behavior can be inspected before sending.
  • Do not expose credentials in responses.
  • Use --debug when delivery behavior needs investigation; it prints SMTP transport logs to stderr and returns envelope/accepted/rejected details in JSON.

Lightweight email watch (optional)

Note: This feature is optional and higher-trust than basic IMAP/SMTP usage. When enabled, email-watch-lite.js invokes the local openclaw CLI to analyze pending emails and may forward summarized email content to another OpenClaw channel (e.g. WhatsApp). Do not enable it unless you understand and accept this behavior.

For low-cost inbox polling, use the detector script instead of a recurring model cron:

cd skills/imap-smtp-mail
node scripts/email-watch-lite.js detect --state ../../memory/email-watch-state.json

To poll and trigger the agent only when pendingUids exist:

cd skills/imap-smtp-mail
node scripts/email-watch-lite.js detect-and-trigger --state ../../memory/email-watch-state.json --channel whatsapp --to +000000000000 --openclaw-bin ~/.npm-global/bin/openclaw --timeout 180 --thinking low

Customize the analysis prompt with --message "your custom instructions".

The email watcher requires the openclaw CLI binary. It is not needed for core IMAP/SMTP operations.

安全使用建议
This appears to be a genuine IMAP/SMTP helper. Before installing: 1) Be aware it requires your mail credentials (IMAP_USER/IMAP_PASS and SMTP_USER/SMTP_PASS) stored in a plaintext .env file by default — use app passwords and set file permissions (the setup.sh already sets chmod 600). 2) The skill relies on additional env/config values (ALLOWED_READ_DIRS, ALLOWED_WRITE_DIRS, EMAIL_ENV_FILE, EMAIL_CONTACTS_FILE) that are not listed in the registry metadata — review and set these to a minimal whitelist to prevent unexpected file access. 3) The inbox watcher can execute the local OpenClaw CLI to forward alerts (child_process.execFileSync) — if you enable the watcher, it can trigger outbound messages via your OpenClaw agent. 4) Run npm install in an isolated environment and review third-party npm package versions if you need higher assurance. 5) If you want to reduce risk, only enable the watcher when necessary and restrict ALLOWED_* dir lists to trusted directories. If you want me to, I can point to the precise lines where the watcher invokes the OpenClaw CLI and where environment variables are loaded so you can audit them.
能力标签
crypto
能力评估
Purpose & Capability
Name/description (IMAP/SMTP mail access) matches the actual files and behavior: Node scripts for IMAP reads, attachment parsing, and SMTP sending. Required binaries (node, npm) and the listed IMAP/SMTP environment variables are appropriate for this purpose.
Instruction Scope
SKILL.md and the scripts limit actions to mailbox operations, attachment parsing, contact lookups, and an optional inbox watcher that can forward alerts via the OpenClaw CLI. The watcher uses child_process.execFileSync to call the local OpenClaw CLI (default 'openclaw') to send alerts; this is coherent with the stated feature but means the skill may invoke local CLI/network actions when the watcher runs. The scripts read/write state and contact files under a workspace and enforce path whitelists for attachments; they do not embed unexpected external endpoints.
Install Mechanism
No external download/install script is embedded; dependencies are standard npm packages listed in package.json (imap, nodemailer, mailparser, pdf-parse, xlsx, dotenv). The repo includes a setup helper that runs npm install locally. Nothing in the install flow downloads arbitrary archives from untrusted URLs.
Credentials
The skill legitimately requires IMAP/SMTP credentials. However, the SKILL.md and scripts also rely on additional environment variables and files not listed in the registry metadata (ALLOWED_READ_DIRS, ALLOWED_WRITE_DIRS, EMAIL_ENV_FILE, EMAIL_CONTACTS_FILE, OPENCLAW_WORKSPACE). The credential file is plaintext and contains passwords; the skill recommends storing it at ~/.openclaw/credentials/imap-smtp-mail.env and uses dotenv. This is expected but means you should protect file permissions and prefer app-specific passwords where supported.
Persistence & Privilege
The skill does not request always:true and is user-invocable only. It writes a local state file under the workspace and may call the OpenClaw CLI to forward alerts; it does not modify other skills or system-wide settings. Autonomous invocation is permitted by platform default, which simply enables the watcher feature to run if invoked.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install imap-smtp-mail
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /imap-smtp-mail 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.4
v1.0.4 — Security hardening + metadata fixes - Fixed symlink bypass in attachment download path validation (now resolves symlinks before checking ALLOWED_WRITE_DIRS) - Fixed ~ expansion in read path validation for attachment sends - Workspace root detection is now resilient (OPENCLAW_WORKSPACE env var > marker file walk > fallback) in smtp.js and email-watch-lite.js - Constrained --state path to workspace in email-watch-lite.js - Removed openclaw from requires.bins (only needed for optional watcher, not core IMAP/SMTP) - Added requires.env for IMAP/SMTP credential vars - Documented that smtp.js test sends a real email - Removed imap-simple dead dependency - Fixed package.json: version, author, description
v1.0.3
v1.0.3 — consistent naming: all paths, credentials, and references now use imap-smtp-mail
v1.0.2
v1.0.2 — fix installed skill path references (skills/imap-smtp-mail/)
v1.0.1
v1.0.1 — declare openclaw as required binary, explicit watcher disclosure, credentials path compatibility note
v1.0.0
v1.0.0 — centralized credentials, generic email watch, reply/reply-all threading, attachment extraction, HTML email, sent-copy via IMAP
元数据
Slug imap-smtp-mail
版本 1.0.4
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 5
常见问题

IMAP SMTP Email 是什么?

Read and send email via IMAP/SMTP using local Node scripts. Use when the agent needs to check inboxes, fetch email content, search messages, download attachm... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 159 次。

如何安装 IMAP SMTP Email?

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

IMAP SMTP Email 是免费的吗?

是的,IMAP SMTP Email 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

IMAP SMTP Email 支持哪些平台?

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

谁开发了 IMAP SMTP Email?

由 Umbra(@mohamed-hammane)开发并维护,当前版本 v1.0.4。

💬 留言讨论