Shared inbox IMAP access gives agents visibility into all email, not just their own
OAuth scope creep — you grant access to the entire mailbox just to trigger one workflow
IMAP polling wastes API calls and adds latency agents can't afford
Multiple agents reading the same inbox create race conditions and duplicate processing
Self-hosting email infrastructure (MX records, spam filtering, MIME parsing) takes weeks
You shouldn't have to build this yourself.
Each agent gets its own email address (e.g. [email protected]). Complete isolation — no shared inbox conflicts.
Email arrives, webhook fires within seconds. No polling, no delays. Your agent reacts in real time.
Agents behind NAT or firewalls? Use Server-Sent Events — outbound-only connection, no exposed ports, no ngrok.
Sender, subject, body, headers, attachments — all delivered as structured JSON. No MIME parsing required.
Replies automatically thread to the originating agent. Full conversation context, zero manual routing.
Only forward emails from specific domains or addresses. Filter noise before the LLM ever sees it.
Set up a dedicated mailhook address for your agent (e.g. [email protected]).
Point the mailhook at your agent's webhook endpoint, or use SSE for outbound-only connections.
An email hits the agent's address. Mailhooks parses and delivers structured JSON instantly.
Your agent receives the webhook, extracts the intent, and executes — no IMAP, no polling.
The agent responds, forwards to a human, or triggers downstream workflows. Thread context is preserved.
Mailhooks delivers this JSON to your agent's webhook endpoint when an email arrives.
{
"id": "msg_agent_abc123",
"from": "[email protected]",
"to": ["[email protected]"],
"subject": "Issue with my subscription",
"text": "Hi, I was charged twice for this month...",
"html": "Hi, I was charged twice for this month...
",
"threadId": "thread_xyz789",
"attachments": [
{
"filename": "invoice.pdf",
"contentType": "application/pdf",
"size": 45678,
"url": "https://files.mailhooks.dev/..."
}
]
}// Agent webhook handler (Express)
app.post('/webhook/agent/email', async (req, res) => {
const { from, subject, text, threadId } = req.body;
// Pass to your agent with clear delimiting
// to prevent prompt injection
const response = await agent.process({
context: `Email from: ${from}
Subject: ${subject}
Body: ${text}`,
threadId,
});
// Agent can reply, escalate, or log
await handleAgentResponse(response, threadId);
res.sendStatus(200);
});
// Or use SSE for firewalled agents:
import { Mailhooks } from '@mailhooks/sdk';
const mailhooks = new Mailhooks({ apiKey: process.env.MAILHOOKS_API_KEY });
mailhooks.realtime.subscribe({
onEmailReceived: (email) => {
agent.process(email);
},
});Every inbox can be configured with sender filtering rules. You can whitelist specific domains or email addresses, or use our webhook to implement your own spam filtering logic. Emails that don't match your rules are automatically rejected.
Webhooks are typically delivered within 100-500ms of email receipt. We process emails in real-time with no polling delays. For high-availability applications, we also offer webhook retries with exponential backoff.
Mailhooks is built specifically for inbound email. We offer simpler setup (no DNS changes required for testing), better attachment handling with direct download URLs, and a developer-first API for fetching emails programmatically—perfect for E2E testing.
Yes! You can connect your own domain with simple DNS configuration. We also provide free subdomains on inbox.mailhooks.dev for testing and development.
We automatically retry failed webhooks with exponential backoff for up to 24 hours. You can also use our API to fetch any missed emails. All emails are stored and accessible via the dashboard.
Takes ~2 minutes — no email infrastructure required.
Sign up for free in seconds.
Get a unique email address for your use case.
Point to your endpoint and start receiving emails.