Urgent.News

What's breaking now, across thousands of outlets.

AI

An inbox your AI agent can read: Cloudflare Email Routing -> Worker -> D1, plus the webmail we added this week

I run a one-person software company where AI agents do most of the work. That has one surprisingly annoying prerequisite: the agents need to receive email. Signup verification codes, platform notices, payment receipts, customer replies — all of it arrives as email, and most of my automation was blocked on "a human has to open the inbox and copy the code out". IMAP polling from a script works, but…

In a story about an AI agent-focused software company, the author faced a challenge: their automated agents needed to receive emails for tasks like signup verification codes, platform notifications, and customer replies. Traditional methods like IMAP polling from a script were unreliable and required individual credentials for each agent. To solve this, the author built an internal mail hub on Cloudflare's free tier.

The hub consisted of an MX record using Cloudflare Email Routing, an Email Worker as the entry point for every domain address, a D1 queue to persist every message, and a CLI for the agent-facing interface. The three key properties that made this solution robust were:

1. D1 served as the durable queue, ensuring messages were safely stored even if the laptop or agent crashed.

2. Classification of messages as verification, platform, spam, or human took place during ingestion, not at read time. This allowed the CLI to filter out non-essential emails for agents.

3. A CLI interface with 20 commands, deterministic exit codes, and easy-to-use functions like drain, wait, cred, triage, done, and exit codes of 0 (nothing to do), 1 (needs attention), and 2 (usage error).

This week, the hub gained a webmail client built on Cloudflare's free tier, consisting of Pages for the SPA, a Worker for the API, and D1 for storage. The hub operates on a simple access model, where one mailbox equals one account and one password. Passwords are secured with PBKDF2-SHA256, a 10,000 iteration salt, and never stored in plaintext.

In addition to the webmail client, the author implemented an admin console with an audit table for every action. The free tier of Cloudflare Email Routing is limited to inbound messages, so the author has not implemented outbound sending capabilities.

Throughout the process, the author emphasizes the importance of building a durable queue, classifying messages early, and providing an agent-friendly CLI interface with clear exit codes. The web UI can be added later, and the author has already built a webmail client for their own use.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in AI

More from Tuesday 20 October →