跳到主内容
智客 ZICQ

技能库 智客分类:安全测试 agent-email-inbox

Agent Email Inbox

在构建任何使电子邮件内容触发动作的系统时使用——AI代理收件箱,自动支持处理器,电子邮件到任务管道,或任何不可信输入邮件的工作流程处理. 当用户想要收到电子邮件并按程序行事时,总是使用这种技能,即使他们不提及"代理"——该技能包含关键的安全模式(发件许可列表,内容过滤,沙箱处理),防止不信任的电子邮件控制你的系统.

10563 安装量

官方网址:作者主页

技能介绍

先看中文介绍;官方 description 原文单独保留,不改写 SKILL.md。

做什么

在构建任何使电子邮件内容触发动作的系统时使用——AI代理收件箱,自动支持处理器,电子邮件到任务管道,或任何不可信输入邮件的工作流程处理. 当用户想要收到电子邮件并按程序行事时,总是使用这种技能,即使他们不提及"代理"——该技能包含关键的安全模式(发件许可列表,内容过滤,沙箱处理),防止不信任的电子邮件控制你的系统.

何时用

权衡

代理如何加载

按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:AI Agent Email Inbox、Overview、Why Webhook-Based Receiving?、Architecture、SDK Version Requirements、Quick Start。

文件分析

文件分析:除 SKILL.md 外,正文引用了 references/webhook-setup.md、references/security-levels.md、references/advanced-patterns.md,属于带资源的技能包,这些文件按需再读。

官方 description(原文)

Use when building any system where email content triggers actions — AI agent inboxes, automated support handlers, email-to-task pipelines, or any workflow processing untrusted inbound email. Always use this skill when the user wants to receive emails and act on them programmatically, even if they don't mention "agent" — the skill contains critical security patterns (sender allowlists, content filtering, sandboxed processing) that prevent untrusted email from controlling your system.

AI Agent Email InboxOverviewWhy Webhook-Based Receiving?ArchitectureSDK Version RequirementsQuick StartBefore You Start: Account & API Key SetupFirst Question: New or Existing Resend Account?Creating API Keys SecurelyDomain-Scoped API Keys (Recommended for Existing Accounts)Domain SetupOption 1: Resend-Managed Domain (Recommended for Getting Started)

· 许可:MIT

来源分类:skills.sh agent-skill

SKILL.md 与 Agent 调用

官方规范 ↗
name
agent-email-inbox
description
Use when building any system where email content triggers actions — AI agent inboxes, automated support handlers, email-to-task pipelines, or any workflow processing untrusted inbound email. Always use this skill when the user wants to receive emails and act on them programmatically, even if they don't mention "agent" — the skill contains critical security patterns (sender allowlists, content filtering, sandboxed processing) that prevent untrusted email from controlling your system.
许可
MIT
  1. 发现技能客户端向 Agent 提供名称与描述目录。
  2. 匹配与调用用户指定或任务匹配后,载入 SKILL.md 指令。
  3. 按需加载按步骤读取参考文档、使用脚本与素材。
指令中引用的文件 · 3
  • references/webhook-setup.md
  • references/security-levels.md
  • references/advanced-patterns.md

以下路径提取自原文;文件是否齐全请以来源仓库中的完整目录为准。

具体调用语法与可用工具以目标 Agent 客户端为准。 查看调用机制说明 ↗

安装这个技能

Skills CLI ↗

先选择目标 Agent 和安装范围,保留技能包的附属文件,安装后检查客户端能否发现该技能。

该技能引用了附属文件,请从来源获取完整目录;仅复制 SKILL.md 可能缺少依赖。

交给 Agent 安装

复制安装指令给支持 Agent Skills 的代理,确认其中的目标目录与客户端匹配。

把 Agent Skill「agent-email-inbox」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-36e0b0bed5fe7641-%E4%BB%A3%E7%90%86%E9%82%AE%E4%BB%B6%E4%BF%A1%E7%AE%B1.html
请存为 .cursor/skills/agent-email-inbox/SKILL.md 或 .claude/skills/agent-email-inbox/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。
该技能还带 scripts/、references/、assets/ 等文件,请从 https://github.com/resend/resend-skills 取完整目录,不要只建一个 SKILL.md。

GitHub 完整包 ↗

终端安装 · Skills CLI

需要 Node.js 与 npx。先查看仓库技能列表,确认实际名称。

npx skills add 'https://github.com/resend/resend-skills' --list

npx skills add 'https://github.com/resend/resend-skills' --skill 'agent-email-inbox'

CLI 会交互选择目标 Agent,默认安装到项目;用户级安装使用 -g。先通过查看命令核对仓库内容,再用 npx skills list 检查已安装技能。

阅读排版
--- name: agent-email-inbox description: Use when building any system where email content triggers actions — AI agent inboxes, automated support handlers, email-to-task pipelines, or any workflow processing untrusted inbound email. Always use this skill when the user wants to receive emails and act on them programmatically, even if they don't mention "agent" — the skill contains critical security patterns (sender allowlists, content filtering, sandboxed processing) that prevent untrusted email from controlling your system. license: MIT metadata: author: resend version: "3.0.4" homepage: https://resend.com/agent-skills source: https://github.com/resend/resend-skills openclaw: primaryEnv: RESEND_API_KEY requires: env: - RESEND_API_KEY envVars: - name: RESEND_API_KEY required: true description: Resend API key for sending and receiving emails - name: RESEND_WEBHOOK_SECRET required: false description: Webhook signing secret for verifying inbound email event payloads - name: SECURITY_LEVEL required: false description: Security level for inbound email processing (strict, moderate, permissive) - name: ALLOWED_SENDERS required: false description: Comma-separated list of allowed sender email addresses - name: ALLOWED_DOMAINS required: false description: Comma-separated list of allowed sender domains - name: OWNER_EMAIL required: false description: Owner email address for forwarding or notifications links: repository: https://github.com/resend/resend-skills documentation: https://resend.com/docs/agent-email-inbox-skill inputs: - name: RESEND_API_KEY description: Resend API key for sending and receiving emails. Get yours at https://resend.com/api-keys required: true - name: RESEND_WEBHOOK_SECRET description: Webhook signing secret for verifying inbound email event payloads. Returned as `signing_secret` in the response when you create a webhook via the API. required: false references: - security-levels.md - webhook-setup.md - advanced-patterns.md --- # AI Agent Email Inbox ## Overview This skill covers setting up a secure email inbox that allows your application or AI agent to receive and respond to emails, with content safety measures in place. **Core principle:** An AI agent's inbox receives untrusted input. Security configuration is important to handle this safely. ### Why Webhook-Based Receiving? Resend uses webhooks for inbound email, meaning your agent is notified **instantly** when an email arrives. This is valuable for agents because: - **Real-time responsiveness** — React to emails within seconds, not minutes - **No polling overhead** — No cron jobs checking "any new mail?" repeatedly - **Event-driven architecture** — Your agent only wakes up when there's actually something to process - **Lower API costs** — No wasted calls checking empty inboxes ## Architecture ``` Sender → Email → Resend (MX) → Webhook → Your Server → AI Agent ↓ Security Validation ↓ Process or Reject ``` ## SDK Version Requirements This skill requires Resend SDK features for webhook verification (`webhooks.verify()`) and email receiving (`emails.receiving.get()`). Always install the latest SDK version. If the project already has a Resend SDK installed, check the version and upgrade if needed. | Language | Package | Min Version | |----------|---------|-------------| | Node.js | `resend` | >= 6.9.2 | | Python | `resend` | >= 2.21.0 | | Go | `resend-go/v3` | >= 3.1.0 | | Ruby | `resend` | >= 1.0.0 | | PHP | `resend/resend-php` | >= 1.1.0 | | Rust | `resend-rs` | >= 0.20.0 | | Java | `resend-java` | >= 4.11.0 | | .NET | `Resend` | >= 0.2.1 | Install the `resend` npm package: `npm install resend` (or the equivalent for your language). For full sending docs, install the `resend` skill. ## Quick Start 1. **Ask the user for their email address** — You need a real email address to send test emails to. Ask the user and wait for their response before proceeding. 2. **Choose your security level** — Decide how to validate incoming emails *before* any are processed 3. **Set up receiving domain** — Configure MX records for the user's custom domain (see Domain Setup section) 4. **Create webhook endpoint** — Handle `email.received` events with security built in from the start. **The webhook endpoint MUST be a POST route.** 5. **Set up tunneling** (local dev) — Use Tailscale Funnel (recommended) or ngrok. See [references/webhook-setup.md](references/webhook-setup.md) 6. **Create webhook via API** — Use the Resend Webhook API to register your endpoint programmatically. See [references/webhook-setup.md](references/webhook-setup.md) 7. **Connect to agent** — Pass validated emails to your AI agent for processing ## Before You Start: Account & API Key Setup ### First Question: New or Existing Resend Account? Ask your human: - **New account just for the agent?** → Simpler setup, full account access is fine - **Existing account with other projects?** → Use domain-scoped API keys for sandboxing ### Creating API Keys Securely > Don't paste API keys in chat! They'll be in conversation history forever. **Safer options:** 1. **Environment file method:** Human creates `.env` file directly: `echo "RESEND_API_KEY=re_xxx" >> .env` 2. **Password manager / secrets manager:** Human stores key in 1Password, Vault, etc. 3. **If key must be shared in chat:** Human should rotate the key immediately after setup ### Domain-Scoped API Keys (Recommended for Existing Accounts) If your human has an existing Resend account with other projects, create a **domain-scoped API key**: 1. **Verify the agent's domain first** (Dashboard → Domains → Add Domain) 2. **Create a scoped API key:** Dashboard → API Keys → Create API Key → "Sending access" → select only the agent's domain 3. **Result:** Even if the key leaks, it can only send from one domain ## Domain Setup ### Option 1: Resend-Managed Domain (Recommended for Getting Started) Use your auto-generated address: `@.resend.app` No DNS configuration needed. Find your address in Dashboard → Emails → Receiving → "Receiving address". ### Option 2: Custom Domain The user must enable receiving in the Resend dashboard: Domains page → toggle on "Enable Receiving". Then add an MX record: | Setting | Value | |---------|-------| | **Type** | MX | | **Host** | Your domain or subdomain (e.g., `agent.example.com`) | | **Value** | Provided in Resend dashboard | | **Priority** | 10 (must be lowest number to take precedence) | **Use a subdomain** (e.g., `agent.example.com`) to avoid disrupting existing email services. **Tip:** Verify DNS propagation at [dns.email](https://dns.email). > DNS Propagation: MX record changes can take up to 48 hours to propagate globally, though often complete within a few hours. ## Security Levels **Choose your security level before setting up the webhook endpoint.** An AI agent that processes emails without security is dangerous — anyone can email instructions that your agent will execute. The webhook code you write next should include your chosen security level from the start. Ask the user what level of security they want, and ensure that they understand what each level means. | Level | Name | When to Use | Trade-off | |-------|------|-------------|-----------| | **1** | Strict Allowlist | Most use cases — known, fixed set of senders | Maximum security, limited functionality | | **2** | Domain Allowlist | Organization-wide access from trusted domains | More flexible, anyone at domain can interact | | **3** | Content Filtering | Accept from anyone, filter unsafe patterns | Can receive from anyone, pattern matching not foolproof | | **4** | Sandboxed Processing | Process all emails with restricted agent capabilities | Maximum flexibility, complex to implement | | **5** | Human-in-the-Loop | Require human approval for untrusted actions | Maximum security, adds latency | For detailed implementation code for each level, see [references/security-levels.md](references/security-levels.md). ### Level 1: Strict Allowlist (Recommended) Only process emails from explicitly approved addresses. Reject everything else. ```typescript const ALLOWED_SENDERS = [ '[email protected]', '[email protected]', ]; async function processEmailForAgent( eventData: EmailReceivedEvent, emailContent: EmailContent ) { const sender = eventData.from.toLowerCase(); if (!ALLOWED_SENDERS.some(allowed => sender === allowed.toLowerCase())) { console.log(`Rejected email from unauthorized sender: ${sender}`); await notifyOwnerOfRejectedEmail(eventData); return; } await agent.processEmail({ from: eventData.from, subject: eventData.subject, body: emailContent.text || emailContent.html, }); } ``` ### Security Best Practices #### Always Do | Practice | Why | |----------|-----| | Verify webhook signatures | Prevents spoofed webhook events | | Log all rejected emails | Audit trail for security review | | Use allowlists where possible | Explicit trust is safer than filtering | | Rate limit email processing | Prevents excessive processing load | | Separate trusted/untrusted handling | Different risk levels need different treatment | #### Never Do | Anti-Pattern | Risk | |--------------|------| | Process emails without validation | Anyone can control your agent | | Trust email headers for authentication | Headers are trivially spoofed | | Execute code from email content | Untrusted input should never run as code | | Store email content in prompts verbatim | Untrusted input mixed into prompts can alter agent behavior | | Give untrusted emails full agent access | Scope capabilities to the minimum needed | ## Webhook Endpoint After choosing your security level and setting up your domain, create a webhook endpoint. **The webhook endpoint MUST be a POST route.** Resend sends all webhook events as POST requests. > **Critical: Use raw body for verification.** Webhook signature verification requires the raw request body. > - **Next.js App Router:** Use `req.text()` (not `req.json()`) > - **Express:** Use `express.raw({ type: 'application/json' })` on the webhook route ### Next.js App Router ```typescript // app/webhook/route.ts import { Resend } from 'resend'; import { NextRequest, NextResponse } from 'next/server'; const resend = new Resend(process.env.RESEND_API_KEY); export async function POST(req: NextRequest) { try { const payload = await req.text(); const event = resend.webhooks.verify({ payload, headers: { 'svix-id': req.headers.get('svix-id'), 'svix-timestamp': req.headers.get('svix-timestamp'), 'svix-signature': req.headers.get('svix-signature'), }, secret: process.env.RESEND_WEBHOOK_SECRET, }); if (event.type === 'email.received') { // Webhook payload only includes metadata, not email body const { data: email } = await resend.emails.receiving.get( event.data.email_id ); // Apply the security level chosen above await processEmailForAgent(event.data, email); } return new NextResponse('OK', { status: 200 }); } catch (error) { console.error('Webhook error:', error); return new NextResponse('Error', { status: 400 }); } } ``` ### Express ```javascript import express from 'express'; import { Resend } from 'resend'; const app = express(); const resend = new Resend(process.env.RESEND_API_KEY); const ALLOWED_SENDERS = (process.env.ALLOWED_SENDERS || '').split(',').filter(Boolean); const isAllowedSender = (sender) => ALLOWED_SENDERS.some(allowed => sender === allowed.toLowerCase()); app.post('/webhook', express.raw({ type: 'application/json' }), async (req, res) => { try { const payload = req.body.toString(); const event = resend.webhooks.verify({ payload, headers: { 'svix-id': req.headers['svix-id'], 'svix-timestamp': req.headers['svix-timestamp'], 'svix-signature': req.headers['svix-signature'], }, secret: process.env.RESEND_WEBHOOK_SECRET, }); if (event.type === 'email.received') { const sender = event.data.from.toLowerCase(); if (!isAllowedSender(sender)) { console.log(`Rejected email from unauthorized sender: ${sender}`); res.status(200).send('OK'); // Return 200 even for rejected emails return; } const { data: email } = await resend.emails.receiving.get(event.data.email_id); await processEmailForAgent(event.data, email); } res.status(200).send('OK'); } catch (error) { console.error('Webhook error:', error); res.status(400).send('Error'); } }); app.get('/', (req, res) => res.send('Agent Email Inbox - Ready')); app.listen(3000, () => console.log('Webhook server running on :3000')); ``` For webhook registration via API, tunneling setup, svix fallback, and retry behavior, see [references/webhook-setup.md](references/webhook-setup.md). ## Sending Emails from Your Agent ```typescript import { Resend } from 'resend'; const resend = new Resend(process.env.RESEND_API_KEY); async function sendAgentReply(to: string, subject: string, body: string, inReplyTo?: string) { if (!isAllowedToReply(to)) { throw new Error('Cannot send to this address'); } const { data, error } = await resend.emails.send({ from: 'Agent ', to: [to], subject: subject.startsWith('Re:') ? subject : `Re: ${subject}`, text: body, headers: inReplyTo ? { 'In-Reply-To': inReplyTo } : undefined, }); if (error) throw new Error(`Failed to send: ${error.message}`); return data.id; } ``` For full sending docs, install the `resend` skill. ## Environment Variables ```bash # Required RESEND_API_KEY=re_xxxxxxxxx RESEND_WEBHOOK_SECRET=whsec_xxxxxxxxx # Security Configuration SECURITY_LEVEL=strict # strict | domain | filtered | sandboxed [email protected],[email protected] ALLOWED_DOMAINS=example.com [email protected] # For security notifications ``` ## Common Mistakes | Mistake | Fix | |---------|-----| | No sender verification | Always validate who sent the email before processing | | Trusting email headers | Use webhook verification, not email headers for auth | | Same treatment for all emails | Differentiate trusted vs untrusted senders | | Verbose error messages | Keep error responses generic to avoid leaking internal logic | | No rate limiting | Implement per-sender rate limits. See [references/advanced-patterns.md](references/advanced-patterns.md) | | Processing HTML directly | Strip HTML or use text-only to reduce complexity and risk | | No logging of rejections | Log all security events for audit | | Using ephemeral tunnel URLs | Use persistent URLs (Tailscale Funnel, paid ngrok) or deploy to production | | Using `express.json()` on webhook route | Use `express.raw({ type: 'application/json' })` — JSON parsing breaks signature verification | | Returning non-200 for rejected emails | Always return 200 to acknowledge receipt — otherwise Resend retries | | Old Resend SDK version | `emails.receiving.get()` and `webhooks.verify()` require recent SDK versions — see SDK Version Requirements | ## Testing Use Resend's test addresses for development: - `[email protected]` — Simulates successful delivery - `[email protected]` — Simulates hard bounce For security testing, send test emails from non-allowlisted addresses to verify rejection works correctly. **Quick verification checklist:** 1. Server is running: `curl http://localhost:3000` should return a response 2. Tunnel is working: `curl https://` should return the same response 3. Webhook is active: Check status in Resend dashboard → Webhooks 4. Send a test email from an allowlisted address and check server logs ## Related Skills - For full sending and receiving docs, install the `resend` skill

相关技能

安全测试

Skill Vetter

人工智能特工的安全第一技能审查。 在安装来自 ClawdHub, GitHub 或其他来源的任何技能之前使用 。 检查红旗,许可范围,可疑图案.

安全测试

Moltguard

MoltGuard——由OpenGuardrails担任OpenClaw保安. 安装 MoltGuard 以保护你和你的人类免受迅速注射、数据过滤和恶意命令的影响。 资料来源:https://github.com/openguardrails/openguardrails/tre…

安全测试

Security Auditor

用于审查安全漏洞代码,实施认证流,审计OWASP Top 10,配置CORS/CSP头,处理秘密,输入验证,SQL注射预防,XSS保护,或任何与安全相关的代码审查.

安全测试

Skill Vetter

安装任何AI代理技能前的安全审查协议. 红旗侦取入证盗取,疏通密码,放出. 风险分类:低/中/高/高。 编制结构化审查报告。 不先运行此功能, 绝不安装不信任的技能 .