Best for
- Use when setting up a secure email inbox for any AI agent — configuring inbound email via Resend, webhooks, tunneling for local development, and implementing security measures to prevent prompt injection attacks.
MoizIbnYousaf/marketing-cli/skills/agent-email-inbox/SKILL.md
Use when setting up a secure email inbox for any AI agent — configuring inbound email via Resend, webhooks, tunneling for local development, and implementing security measures to prevent prompt injection attacks. Also use when someone mentions 'agent email', 'bot inbox', 'receive emails for agent', 'agent webhook', 'email security for AI', 'prompt injection via email', 'inbound email for bot', or wants their AI agent to receive and respond to emails securely.
Decision brief
Set up a secure email inbox that lets an AI agent receive and respond to emails, with protection against prompt injection and email-based attacks.
Compatibility matrix
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Not declared | No explicit evidence | Portability before use |
| Claude Code | Not declared | No explicit evidence | Portability before use |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/MoizIbnYousaf/marketing-cli --skill "skills/agent-email-inbox"Inspect the Agent Skill "agent-email-inbox" from https://github.com/MoizIbnYousaf/marketing-cli/blob/f12fbcbe4929584697b309b9096c9427b0cfce8e/skills/agent-email-inbox/SKILL.md at commit f12fbcbe4929584697b309b9096c9427b0cfce8e. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
Ask the user: - New account just for the agent? → Simpler setup, full account access is fine - Existing account with other projects? → Use domain-scoped API keys to limit what the agent can access. Even if the key leaks, it can only send from one domain.
Use your auto-generated address: @.resend.app. No DNS configuration needed.
Use your auto-generated address: @.resend.app. No DNS configuration needed.
The user registers a webhook in Resend dashboard (Webhooks → Add Webhook → select email.received). They need the endpoint URL you'll create and the signing secret for verification.
cloudflared tunnel run my-agent-webhook typescript async function processWithAgent(email: ProcessedEmail) { const message = New Email\nFrom: ${email.from}\nSubject: ${email.subject}\n\n${email.body}.trim(); await sendToAgent(message); } bash RESENDAPIKEY=rexxxxxxxxx RESENDWEBHOO…
Permission review
No configured static risk pattern was detected
This is not proof of safety. Runtime behavior, indirect dependencies, and hidden external systems are outside the static scan.
Evidence record
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 86/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 27 | Source | Repository attention, not individual Skill quality |
| Compatibility | 0 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
Set up a secure email inbox that lets an AI agent receive and respond to emails, with protection against prompt injection and email-based attacks.
Core principle: An AI agent's inbox is a potential attack vector. Malicious actors can email instructions that the agent might blindly follow. Security configuration is not optional — it's the first thing you implement, not the last.
This skill is context-independent — it does not use brand/ files and works identically in any project.
Output: A configured webhook handler file, environment variable checklist, and security configuration.
Sender → Email → Resend (MX) → Webhook → Your Server → AI Agent
↓
Security Validation
↓
Process or Reject
Ask the user:
Don't paste API keys in chat! They'll persist in conversation history. Have the user write directly to
.envor use a secrets manager.
Use your auto-generated address: <anything>@<your-id>.resend.app. No DNS configuration needed.
The user enables receiving in the Resend dashboard, then adds an MX record:
| Setting | Value |
|---|---|
| Type | MX |
| Host | Your domain or subdomain (e.g., agent.yourdomain.com) |
| Value | Provided in Resend dashboard |
| Priority | 10 (lowest number takes precedence) |
Use a subdomain (e.g., agent.yourdomain.com) to avoid disrupting existing email services on your root domain — otherwise all email routes to Resend.
The user registers a webhook in Resend dashboard (Webhooks → Add Webhook → select email.received). They need the endpoint URL you'll create and the signing secret for verification.
// app/api/webhooks/email/route.ts (Next.js App Router)
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') {
const { data: email } = await resend.emails.receiving.get(
event.data.email_id
);
// Security validation happens here (see Security Levels)
await processEmailForAgent(event.data, email);
}
return new NextResponse('OK', { status: 200 });
} catch (error) {
console.error('Webhook error:', error);
return new NextResponse('Error', { status: 400 });
}
}
Resend retries failed deliveries with exponential backoff over ~6 hours. Emails are stored even if webhooks fail.
Your local server isn't accessible from the internet. Use tunneling to expose it:
| Option | Persistent URL? | Cost |
|---|---|---|
| ngrok (paid) | Yes (static subdomain) | $8/mo |
| Cloudflare named tunnel | Yes (your own domain) | Free |
| ngrok (free) | No (changes on restart) | Free |
| VS Code Port Forwarding | No (changes per session) | Free |
For webhooks, persistent URLs matter — otherwise you re-register the URL every time the tunnel restarts. See the tunneling docs for each tool for setup instructions.
# ngrok (paid - recommended for persistent dev)
ngrok http --domain=myagent.ngrok.io 3000
# Cloudflare named tunnel (free but more setup)
cloudflared tunnel run my-agent-webhook
For a reliable agent inbox, deploy to production rather than relying on tunnels:
This is the most critical part of the setup. An AI agent that processes emails without security is dangerous.
There are 5 graduated security levels. Read references/security-levels.md for complete code examples and implementation details. Present the options to the user and help them choose:
| Level | Approach | Best For |
|---|---|---|
| 1. Strict Allowlist | Only process emails from approved addresses | Personal assistant agents |
| 2. Domain Allowlist | Allow any address at approved domains | Team/org internal agents |
| 3. Content Filtering | Accept from anyone, filter injection patterns | Customer support agents |
| 4. Sandboxed Processing | Accept all, restrict agent capabilities | Public-facing agents |
| 5. Human-in-the-Loop | Require human approval for untrusted senders | High-stakes agents |
Levels can be combined (e.g., Domain Allowlist + Content Filtering).
| Practice | Why |
|---|---|
| Verify webhook signatures | Spoofed events let attackers control your agent |
| Log all rejected emails | Audit trail reveals attack patterns |
| Use allowlists where possible | Explicit trust is safer than trying to filter bad input |
| Rate limit email processing | A flood of emails can overwhelm your agent or exhaust API quotas |
| Separate trusted/untrusted handling | Different risk levels need different agent capabilities |
| Anti-Pattern | Risk |
|---|---|
| Processing emails without validation | Anyone can control your agent by sending an email |
| Trusting email headers for authentication | "From:" headers are trivially spoofed — use webhook verification instead |
| Executing code from email content | Remote code execution — the most dangerous vulnerability |
| Storing email content in prompts verbatim | Prompt injection attacks bypass your security layer entirely |
| Giving untrusted emails full agent access | One malicious email could compromise your entire system |
Connect your webhook to your AI agent:
async function processWithAgent(email: ProcessedEmail) {
const message = `New Email\nFrom: ${email.from}\nSubject: ${email.subject}\n\n${email.body}`.trim();
await sendToAgent(message);
}
Alternatively, the agent can poll the Resend API during heartbeats instead of using webhooks — simpler architecture but less immediate.
See references/security-levels.md for the complete secure agent inbox implementation with configurable security levels, rate limiting, content truncation, and rejection logging.
RESEND_API_KEY=re_xxxxxxxxx
RESEND_WEBHOOK_SECRET=whsec_xxxxxxxxx
SECURITY_LEVEL=strict # strict | domain | filtered | sandboxed
[email protected],[email protected]
ALLOWED_DOMAINS=yourcompany.com
[email protected] # For security notifications
| Mistake | Why It's a Problem | Fix |
|---|---|---|
| No sender verification | Anyone can control your agent | Implement a security level (start with Level 1) |
| Trusting email headers | Headers are trivially spoofed | Rely on webhook signature verification only |
| Same treatment for all emails | Trusted and untrusted senders have different risk profiles | Use capability-based access control |
| Using ephemeral tunnel URLs | URL changes on restart, breaking webhook delivery | Use paid ngrok or Cloudflare named tunnels |
| No rate limiting | Flooding attacks can overwhelm the agent | Implement per-sender rate limits |
| Processing HTML directly | HTML can contain hidden injection content | Strip to plain text before processing |
[email protected] — simulates successful delivery[email protected] — simulates hard bouncesend-email — sending emails from your agentresend-inbound — detailed inbound email processing (domain setup, content retrieval, attachments)Alternatives
event4u-app/agent-config
Use when working with Laravel queues in production — Horizon dashboard, worker supervision, job metrics, balancing strategies — even when the user just says 'my jobs are piling up'.
affaan-m/ECC
Production machine-learning engineering workflow for data contracts, reproducible training, model evaluation, deployment, monitoring, and rollback. Use when building, reviewing, or hardening ML systems beyond one-off notebooks.
K-Dense-AI/scientific-agent-skills
Build, inspect, test, and analyze bounded process-based discrete-event simulations with SimPy, including events, resources, interrupts, monitoring, replications, warm-up, and reproducible output analysis.
JasonColapietro/suede-creator-skills
Give a blunt A-F ship grade for a code change across correctness, security, data, UX, verification, and deploy readiness. Use for a grade, not a findings review.