How-to

How to Give an AI Agent Its Own Email Address in 2026

Akshay Sarode 8 min read
Direct answer

An agent needs an inbox, not a send button. There are three real ways to build one: run your own mail server with Postfix and OpenDKIM (full control, budget a weekend or more if you've never configured SPF, DKIM, and DMARC before), use a managed inbox API like Ujex Postbox where the mail server and DNS complexity are already handled and you get send, receive, and threading through an API call, or hack together catch-all forwarding into an inbox you already have (fast to set up, but you inherit spam filtering, deliverability, and thread-tracking as your own problem). For most agent projects that need real back-and-forth email, the managed path gets you a working round trip in under an hour.

I gave an agent an email address for the first time about a year ago and made the obvious rookie mistake: I wired up outbound SMTP credentials, felt very pleased with myself, and then discovered the agent had no idea what to do when someone actually replied. It could send. It could not receive. It definitely could not tell that a reply three days later belonged to the same conversation as the message it had sent on a Tuesday. That's not an email address. That's a megaphone.

A send-only address is not an inbox

Most "give your agent an email address" tutorials stop at outbound. You grab an SMTP relay, drop in an API key, and the agent can fire messages at the world. That's genuinely useful for notifications, one-way status reports, alerts. It falls apart the moment the agent's job involves talking to a vendor, following up on an unpaid invoice, or negotiating a meeting time, because all of those tasks require the agent to read a reply and know which conversation it belongs to.

Receiving mail is a different engineering problem than sending it. You need an MX record pointing somewhere willing to accept mail for your domain, something on the other end that parses that mail, and a way to tie a new inbound message back to the thread it's replying to. None of that exists if you only set up outbound SMTP. It's the difference between a phone that can only dial out and a phone number someone can actually call you back on.

Three real ways to build the inbox

Once you accept that an agent needs real inbound mail, there are three approaches people actually use in production. None of them is wrong. They trade setup time against control, and it's worth being honest about which one you're optimizing for before you pick.

ApproachSetup timeWho owns deliverabilityThreading
Run your own mail serverA weekend or more if new to DKIM/SPF/DMARCYouYou build it
Managed inbox API (e.g. Postbox)Under an hourThe providerBuilt in, via a threadKey
Catch-all forwarding hackMinutesWhoever owns the existing inboxYou reverse-engineer it

Option 1: run your own mail server

This means Postfix plus OpenDKIM plus the DNS records that make mail servers trust you: SPF, so receiving servers know your box is allowed to send for your domain; DKIM, so messages are cryptographically signed; DMARC, so you can tell mailbox providers what to do with mail that fails those checks. Then you need something that accepts inbound mail, typically over LMTP or a similar local handoff, and parses it into whatever format your agent expects, threading it by matching headers or a custom identifier you inject yourself.

If you've never configured DKIM key rotation or watched a fresh sending IP's reputation build up over its first few weeks, budget real time for this. None of it is conceptually hard, but every step has a way to silently fail: a missing DKIM selector, an SPF record with the wrong include, a DMARC policy set to reject before you've verified alignment. I've watched this eat a full weekend for someone who was otherwise a strong backend engineer, not because any single piece was difficult, but because debugging "why did Gmail silently drop this message" with zero visibility into someone else's spam pipeline ate most of the time.

The upside is real, though. No third party sits in the loop reading your agent's mail. You're not depending on anyone else's uptime or pricing changes. And if you're already running mail infrastructure for other reasons, extending it to cover an agent is a genuinely small marginal cost. If control and independence matter more to you than time, this is the correct answer, not a consolation prize.

Option 2: a managed inbox API

This is the path where somebody else already built and operates the mail server, and you interact with it through an API and a webhook. Ujex's email subsystem, Postbox, works this way: outbound and inbound mail run through a real Postfix and OpenDKIM setup that Ujex operates on a Hetzner VM, with a small LMTP/HTTP bridge that takes inbound mail and forwards it into the platform as a normal API event. Messages in a conversation are threaded by a threadKey, so your agent pulls back "everything in this conversation" instead of parsing References and In-Reply-To headers by hand.

The tradeoff is the obvious one: you're depending on somebody else's mail server. In exchange you skip DKIM key management, SPF record debugging, and the slow reputation-building period a brand-new sending IP has to go through. Ujex is Apache-2.0 and self-hostable, including the SDKs: Python's ujex-postbox on PyPI ships with langchain, llamaindex, and crewai extras, there's a Go SDK (ujex-go) and a JavaScript client (@ujexdev/client), and a CLI and an MCP server (@ujexdev/postbox-mcp) if your agent framework talks MCP directly instead of calling a REST API. So "managed" doesn't mean locked in. You can start on the managed tier and run the same code against a self-hosted deployment later if the tradeoff stops making sense.

Inbound mail arrives at MX AGENT threadKey: abc123 Reply goes out signed with DKIM next reply lands under the same threadKey
Mail comes in, the agent reads and replies, and the next message from the other side lands back in the same thread instead of starting a new conversation.

Wiring up a managed inbox, step by step

This is the fastest of the three paths to a working round trip, so it's worth walking through concretely. This is the general shape whether you use Postbox or another provider built the same way; the specifics of the DKIM record format and the webhook payload will differ slightly by provider.

Try it: five steps to a working inbox

Don't point your root domain at a new provider on day one. Carve out something like agent.yourcompany.com so a bad send or a misconfigured record can't touch your main domain's sending reputation. It's also just the common pattern: nobody expects an agent to email from your company's primary domain.

Add an MX record so inbound mail for that subdomain actually routes to the provider's mail server, plus the DKIM TXT record they give you so outbound mail gets signed and passes verification on the receiving end. This is the part Option 1 makes you build from scratch; here it's copying in two DNS records and waiting for propagation.

Stand up an HTTP endpoint in your app that the provider calls when new mail lands for your agent's address. This is the other end of the LMTP/HTTP bridge: the provider's mail server accepts the message, parses it, and forwards it to you as a normal HTTP POST instead of raw SMTP.

Before your code trusts a payload claiming "new mail for your agent," verify the HMAC signature computed over the raw request body, using a timing-safe comparison rather than a plain string equality check. Skip this step and anyone who finds your webhook URL can POST a forged "received mail" event and get your agent to act on content that was never actually sent to it.

Send a message from the agent's address to a real inbox you control, reply to it, and check two things: that the webhook fires with the reply's content, and that it's tagged with the same threadKey as the original outbound message rather than showing up as an unrelated new conversation.

Option 3: the catch-all forwarding hack

The fastest thing you can technically do is point a catch-all address at an inbox you already have (a shared team inbox, a Gmail account with a filter, whatever), and write a script that polls it or forwards new mail into your app. This works, in the sense that mail arrives and you can parse it. It is fragile in every direction that matters for a production agent.

There's no real threading: you're guessing at conversation boundaries from subject lines or some ad hoc convention you invented, and that guessing breaks the moment someone replies without "Re:" in the subject or forwards the message to a third person. Spam filtering is now your problem, not a mail provider's, so you either build a filter yourself or your agent eventually processes a phishing email as a legitimate task. And deliverability rides entirely on whatever reputation the existing inbox already has, which means a spike in agent-sent volume can quietly tank the sender score of an address a human also depends on for real mail.

It's a reasonable thing to do for a two-day prototype where you just want to see if the idea works before investing in anything more durable. It's not something I'd want running past that stage.

Which one is actually worth your time

Self-hosting (Option 1) is worth it when you already run mail infrastructure, when you need zero third parties in the path for compliance or trust reasons, or when your agent's mail volume is high enough that a managed provider's pricing stops making sense. It's a real cost in setup time and ongoing operational attention: DKIM keys don't rotate themselves, and a mail server is one more system that can page you at 2am.

A managed inbox API is worth it when you want to ship the feature this week, when you don't want an on-call rotation for a mail server, or when you'd rather spend engineering time on the agent's actual task than on SPF record syntax. Because Postbox is Apache-2.0 and self-hostable, choosing it now doesn't lock you in forever. You can start on the managed side and move to self-hosted later if your volume or compliance requirements change, without rewriting the part of your agent that reads and writes threaded conversations.

Skip the catch-all hack unless you're explicitly building a two-day proof of concept. It's the only one of the three that doesn't scale into something you'd trust with a real workflow.

FAQ

Does my agent need its own dedicated domain?

Not strictly. A subdomain works fine and is the common pattern, something like agent.yourcompany.com. Keeping the agent on a subdomain also isolates its sending reputation from your root domain's.

How does email threading actually work?

A threadKey ties a series of messages together into one conversation the agent can read back as a unit, instead of the agent having to parse References and In-Reply-To headers itself to figure out which messages belong together.

What stops someone from faking a "received mail" webhook call to trick my agent?

An HMAC signature computed over the raw request body, checked with a timing-safe comparison. If the signature doesn't match, the payload didn't come from the provider's mail server, and you reject it before your agent ever sees the content.

Can I switch from a managed provider to self-hosting later?

If the SDK is Apache-2.0 and the service is self-hostable, yes. The code your agent uses to send, receive, and read threads doesn't need to change, only where the mail server actually runs.

Is a managed inbox API more secure than running my own mail server?

Not automatically. What actually matters is whether inbound delivery is authenticated, such as an HMAC-signed webhook, and whether outbound mail is properly DKIM-signed. A self-hosted server configured correctly is just as secure. A managed API without signature verification on its webhooks is not more secure just because someone else runs the server.