Set an outbound allowlist on the agent's inbox and list the domains or addresses it may write to. OpenMail checks every recipient on its own servers before a send goes out, and the agent's key can't read the rule or change it. If an email talks the agent into writing to a stranger, the send comes back as a 403.
In a Hacker News thread in late November, one developer wrote: "I want my agent/LLM to be able to read and send emails to domains I approve of. But email services don't allow delegated access like this." A rule in the prompt won't hold. The model reads your prompt and every email it receives, and any email can tell it to ignore you. The check has to live outside the model.
Set the allowlist on the inbox
One call does it. Run it with your account-wide key, from your own backend:
# Run from your backend with the account-wide key, never from the agent.
curl -X PUT "https://api.openmail.sh/v1/policy?inboxId=$INBOX_ID" \
-H "Authorization: Bearer $OPENMAIL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"outbound": { "mode": "allowlist", "rules": [
{ "type": "allow", "value": "partner.com" },
{ "type": "allow", "value": "yourcompany.com" },
{ "type": "allow", "value": "ops@supplier.example" }
]}
}'A rule is an exact address (ops@supplier.example) or a whole domain (partner.com). An allowlist with no rules denies everything, so a setup mistake fails closed. PUT replaces the rules it sets, so running it twice gives the same result. The account owner can also edit rules in the console.
Give the agent a key that can't touch the rules
Then mint the key the agent runs with. An inbox-scoped key can read and send from its one inbox and nothing else.
# The token is shown once. Put it in the agent's OPENMAIL_API_KEY.
curl -X POST "https://api.openmail.sh/v1/inboxes/$INBOX_ID/api-keys" \
-H "Authorization: Bearer $OPENMAIL_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "name": "invoice-agent" }'That key gets a 403 on every policy endpoint, reads included. The agent can't widen its own reach, and it can't even see the list. Agent keys in the docs covers rotation and revoking.
What happens when the agent tries anyway
Every address a send can reach is checked: to, cc, bcc and replyTo. Cc is checked after the thread's earlier recipients are added, so a reply can't slip a new address past the rule. One address outside the list rejects the whole send. Nobody gets a copy, and the rejected send doesn't count against your rate limits.
// 403 Forbidden
{
"error": "recipient_not_permitted",
"recipient": "stranger@elsewhere.com",
"message": "Sending to stranger@elsewhere.com is not permitted by this inbox's outbound recipient policy."
}The REST API, the CLI, the console, replies and forwards all pass the same check. Return the error to the agent as a tool result, so it tells the user instead of retrying.
One rule for a whole customer
If you run agents for many customers, give each customer a pod (a sub-account) and set the allowlist once on the pod. Every inbox in it inherits the rule. Blocks always win: a block on the account or the pod can't be cancelled by an allow on one inbox.
# Account floor: nobody on the account can email this domain.
curl -X POST "https://api.openmail.sh/v1/policy/rules" \
-H "Authorization: Bearer $OPENMAIL_API_KEY" -H "Content-Type: application/json" \
-d '{ "type": "block", "value": "known-bad.example", "direction": "outbound" }'
# Pod: every agent of this customer may email only the customer's domain.
curl -X PUT "https://api.openmail.sh/v1/policy?podId=$POD_ID" \
-H "Authorization: Bearer $OPENMAIL_API_KEY" -H "Content-Type: application/json" \
-d '{ "outbound": { "mode": "allowlist", "rules": [{ "type": "allow", "value": "tenant.com" }] } }'Email for AI agent platforms covers the rest of running one pod per customer, including what it costs at 1,000 inboxes.
See what was refused
Every refused send is logged as a send_rejected event, with the address and the scope whose rule matched. Rule and mode changes are logged too. Entries can't be edited or deleted, not even over the API.
curl -H "Authorization: Bearer $OPENMAIL_API_KEY" \
"https://api.openmail.sh/v1/policy/audit?action=send_rejected&since=2026-12-01T00:00:00Z"What an allowlist doesn't stop
An allowlist limits who the agent writes to, not whether it should. As another Hacker News commenter put it: "What the list doesn't stop is the model deciding to send, based on something it read." A planted email can still get the agent to send the wrong thing to a partner you approved. How to keep prompt injection out of an agent's inbox covers that side.
The rules have limits too. A domain rule doesn't match its subdomains, and there are no wildcards. Rules check addresses only, not the subject, body or attachments.
For sends that matter, keep a person in the loop. Per-inbox send limits also cap a runaway loop: every inbox starts at 10 sends a minute and 200 recipients a day.
An allowlist also doesn't fit an agent that must reach anyone, such as a sales agent emailing new prospects every day.
How other agent email APIs handle it
AgentMail also checks recipients on its side, with send lists by address or domain. Its scopes combine differently: a match on an inbox's list means the pod and org lists aren't checked. Nylas says the check belongs in your code, in a wrapper the agent must call before every send. Pick Nylas when the agent has to work in mailboxes your users already have, and write that wrapper.
| Provider | Where the check runs | Scopes | Denied send |
|---|---|---|---|
| OpenMail | On OpenMail's side, in the send path every surface uses | Account, pod or inbox. Rules add up across scopes, and a block anywhere wins | 403 recipient_not_permitted, nothing is sent |
| AgentMail | On AgentMail's side, with send allow and send block lists | Organisation, pod or inbox. A match on the inbox list skips the pod and org lists | 403 message_rejected, nothing is sent |
| Nylas | In your own code, before you call the send endpoint. Nylas stores no recipient policy | Whatever your wrapper checks | Whatever your wrapper does |
From each provider's docs, checked December 1, 2026. The full OpenMail reference is in sender rules, and how an agent receives email and replies shows the agent side.
Frequently asked questions
Can an AI agent change its own allowlist?
No. An inbox-scoped key gets a 403 on every policy endpoint, reads included. Set the rules from your backend with your account-wide key, or in the console, and never give that key to the agent.
Does the allowlist cover cc, bcc and reply-to?
Yes. OpenMail checks to, cc, bcc and replyTo on every send, and cc is checked after the thread's earlier recipients are added. One address outside the list rejects the whole send.
Does allowing a domain cover its subdomains?
No. A rule for partner.com covers bob@partner.com but not bob@mail.partner.com. Add each domain you want covered. There are no wildcards or regular expressions.
Do I need a paid plan for sender rules?
No. Sender rules are available on every OpenMail plan, the free one included.
Can I also limit who the agent receives mail from?
Yes. Inbound has its own mode and rules. Mail from a sender outside the list is dropped before it is stored and fires no webhook. The sender gets no bounce, and the drop shows up in the history.



