Agent Email Inbox logo

Agent Email Inbox

Community
MoizIbnYousaf
agent-email-inbox

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.

Overview

PublisherMoizIbnYousaf
Repositorymarketing-cli
Skill nameagent-email-inbox
Stars
35
Forks
5
Bundled files
1
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by MoizIbnYousaf on GitHub. Read the source before you install it.

Installation

Install the Agent Email Inbox AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/MoizIbnYousaf/marketing-cli/tree/main/skills/agent-email-inbox
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/MoizIbnYousaf/marketing-cli.git /tmp/marketing-cli
mkdir -p .claude/skills
cp -r /tmp/marketing-cli/skills/agent-email-inbox .claude/skills/agent-email-inbox
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Agent Email Inbox in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Agent Email Inbox on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Agent Email Inbox is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

AI Agent Email Inbox

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.

On Activation

  1. Ask the user which agent needs an email inbox and what framework they're using (Next.js, Express, etc.).
  2. Determine environment: local development or production deployment.
  3. Walk through domain setup (Resend-managed or custom).
  4. Set up webhook endpoint with signature verification.
  5. If local dev: configure tunneling.
  6. Implement security level — read references/security-levels.md and present options to the user.
  7. Connect webhook to agent processing.

Output: A configured webhook handler file, environment variable checklist, and security configuration.

Architecture

Sender → Email → Resend (MX) → Webhook → Your Server → AI Agent
                                              ↓
                                    Security Validation
                                              ↓
                                    Process or Reject

Before You Start: Account & API Key Setup

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.

Don't paste API keys in chat! They'll persist in conversation history. Have the user write directly to .env or use a secrets manager.

Domain Setup

Option 1: Resend-Managed Domain (Recommended for Getting Started)

Use your auto-generated address: <anything>@<your-id>.resend.app. No DNS configuration needed.

Option 2: Custom Domain

The user enables receiving in the Resend dashboard, then adds an MX record:

SettingValue
TypeMX
HostYour domain or subdomain (e.g., agent.yourdomain.com)
ValueProvided in Resend dashboard
Priority10 (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.

Webhook Setup

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.

typescript
// 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.

Local Development with Tunneling

Your local server isn't accessible from the internet. Use tunneling to expose it:

OptionPersistent URL?Cost
ngrok (paid)Yes (static subdomain)$8/mo
Cloudflare named tunnelYes (your own domain)Free
ngrok (free)No (changes on restart)Free
VS Code Port ForwardingNo (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.

bash
# 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

Production Deployment

For a reliable agent inbox, deploy to production rather than relying on tunnels:

  • Serverless (Vercel, Netlify, Cloudflare Workers) — zero server management, automatic HTTPS
  • VPS/cloud — webhook handler runs alongside your agent, use nginx/caddy for HTTPS
  • Existing infrastructure — add webhook route to your agent's existing web server

Security Levels

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:

LevelApproachBest For
1. Strict AllowlistOnly process emails from approved addressesPersonal assistant agents
2. Domain AllowlistAllow any address at approved domainsTeam/org internal agents
3. Content FilteringAccept from anyone, filter injection patternsCustomer support agents
4. Sandboxed ProcessingAccept all, restrict agent capabilitiesPublic-facing agents
5. Human-in-the-LoopRequire human approval for untrusted sendersHigh-stakes agents

Levels can be combined (e.g., Domain Allowlist + Content Filtering).

Security Best Practices

PracticeWhy
Verify webhook signaturesSpoofed events let attackers control your agent
Log all rejected emailsAudit trail reveals attack patterns
Use allowlists where possibleExplicit trust is safer than trying to filter bad input
Rate limit email processingA flood of emails can overwhelm your agent or exhaust API quotas
Separate trusted/untrusted handlingDifferent risk levels need different agent capabilities

What to Avoid

Anti-PatternRisk
Processing emails without validationAnyone 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 contentRemote code execution — the most dangerous vulnerability
Storing email content in prompts verbatimPrompt injection attacks bypass your security layer entirely
Giving untrusted emails full agent accessOne malicious email could compromise your entire system

Agent Integration

Connect your webhook to your AI agent:

typescript
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.

Complete Example

See references/security-levels.md for the complete secure agent inbox implementation with configurable security levels, rate limiting, content truncation, and rejection logging.

Environment Variables

bash
RESEND_API_KEY=re_xxxxxxxxx
RESEND_WEBHOOK_SECRET=whsec_xxxxxxxxx
SECURITY_LEVEL=strict                    # strict | domain | filtered | sandboxed
ALLOWED_SENDERS=you@example.com,trusted@example.com
ALLOWED_DOMAINS=yourcompany.com
OWNER_EMAIL=you@example.com             # For security notifications

Common Mistakes

MistakeWhy It's a ProblemFix
No sender verificationAnyone can control your agentImplement a security level (start with Level 1)
Trusting email headersHeaders are trivially spoofedRely on webhook signature verification only
Same treatment for all emailsTrusted and untrusted senders have different risk profilesUse capability-based access control
Using ephemeral tunnel URLsURL changes on restart, breaking webhook deliveryUse paid ngrok or Cloudflare named tunnels
No rate limitingFlooding attacks can overwhelm the agentImplement per-sender rate limits
Processing HTML directlyHTML can contain hidden injection contentStrip to plain text before processing

Testing

  • delivered@resend.dev — simulates successful delivery
  • bounced@resend.dev — simulates hard bounce
  • Send from non-allowlisted addresses to verify rejection works

Related Skills

  • send-email — sending emails from your agent
  • resend-inbound — detailed inbound email processing (domain setup, content retrieval, attachments)

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Agent Email Inbox AI skill do?

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.

Why use Agent Email Inbox on TypingMind?

Because you install it once and use it with any model. Agent Email Inbox is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Agent Email Inbox in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/MoizIbnYousaf/marketing-cli/tree/main/skills/agent-email-inbox. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Agent Email Inbox?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Agent Email Inbox?

As many as you like. As long as a model supports skills, you can use Agent Email Inbox with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Agent Email Inbox AI skill free?

Yes. It is published on GitHub by MoizIbnYousaf under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇