---
title: How do you stop an AI agent from emailing people outside the company?
url: https://opencontroller.lyzr.com/blog/stop-ai-agents-sending-external-email
published: 2026-11-15
updated: 2026-11-15
author: Lyzr
---

# How do you stop an AI agent from emailing people outside the company?

**Use layered controls, not a prompt instruction. Restrict the agent's email tool to approved recipient domains, scope its mailbox permissions, add a mail-system rule that blocks external delivery from the agent's mailbox, and alert on every blocked attempt. Each layer catches what the one before it misses.**

An email to an external recipient is one of the clearest irreversible actions an agent can take. Once it leaves your tenant, you cannot recall it. This guide is part of the runtime control series; the pillar is [how to stop a rogue AI agent](/blog/how-to-stop-a-rogue-ai-agent).

## Why isn't a system prompt enough?

A line such as "never email external addresses" is a request to the model, not a control. Prompt injection, a confused instruction or a model change can all override it. OWASP lists prompt injection as a top risk for LLM applications for exactly this reason. Controls that hold must sit outside the model: in the tool, in the identity system and in the mail platform.

## What are the layers?

| Layer | Control | What it stops | What it misses |
|---|---|---|---|
| 1. Tool | Recipient domain allowlist inside the send tool | Most external sends before any API call | Agents with a second path to email |
| 2. Identity | Scope the app's send permission to one mailbox | The agent sending as other users | External recipients from its own mailbox |
| 3. Gateway | Check tool-call arguments and outputs in the traffic path | Addresses or data that slip past the tool | Calls that bypass the gateway |
| 4. Mail system | Transport or delivery rule on the agent's mailbox | Any external delivery, whatever the path | Nothing on that mailbox; it is the backstop |
| 5. Monitoring | Alert on blocked attempts | Repeat attempts going unnoticed | — |

## How do you build the tool-level allowlist?

Do it in code, not in the model's instructions.

1. Give the agent a dedicated send tool. Do not hand it a general API client.
2. Parse every address in To, Cc, Bcc and Reply-To.
3. Lower-case and normalise the domain, then compare it against an allowlist of your own domains.
4. Reject the whole call if any address fails. Do not silently drop the bad one.
5. Return a clear error to the agent, so it does not retry with a variation.
6. Log the rejected call with the agent ID, version and attempted recipients.

If some agents genuinely need to email customers, give them a separate tool with its own allowlist, rate limit and, where the risk justifies it, a draft-and-release step.

## How do you scope the mailbox in Microsoft 365?

An app registered with the Microsoft Graph Mail.Send application permission can, by default, send as any mailbox in the tenant. That is far too broad for an agent. Exchange Online lets administrators restrict an application to specific mailboxes, using RBAC for Applications (the successor to application access policies). Scope the agent to its own mailbox only.

Then add a backstop in Exchange. [Mail flow rules](https://learn.microsoft.com/en-us/exchange/security-and-compliance/mail-flow-rules/mail-flow-rules) can match a sender and a recipient located outside the organisation, then reject the message and notify an administrator. This catches external sends even if the tool allowlist has a bug.

## How do you do the same in Google Workspace?

Put the agent's account in its own organisational unit. In the Admin console, Gmail compliance settings include a [restrict delivery setting](https://support.google.com/a/answer/2640542) that limits which addresses or domains users in that unit can send to and receive from. Allow only your own domains. If the agent uses a service account with domain-wide delegation, limit the delegated scopes and the accounts it impersonates.

## What should you monitor?

- Every rejection at the tool, gateway or mail layer, with agent ID and version.
- A spike in rejections from one agent, which often signals prompt injection or a bad release.
- New email-capable tools or MCP servers attached to any agent.
- Agents whose service account holds tenant-wide send permissions.

Repeated blocked attempts should page someone. They mean the agent is trying, and only your controls are stopping it. For broader patterns, see [how to detect data exfiltration by AI agents](/blog/detect-data-exfiltration-by-ai-agents) and [how to limit which tools each agent can call](/blog/limit-which-tools-each-ai-agent-can-call).

## How Opencontroller does this

Opencontroller's registry shows which agents hold email-capable tools and MCP servers. Posture flags risky permissions and configuration, such as broad send rights. When traffic runs through the Agent Gateway or LLM Gateway, policy as code can allow, redact or block in the path. Behavioural-deviation monitoring raises alerts and can automatically quarantine an agent that keeps trying. Mail-system rules stay in Microsoft 365 or Google Workspace, where they belong. [Book a demo](https://www.lyzr.ai/book-demo/) to see it on your estate, or read [what an AI agent control plane is](/blog/what-is-an-ai-agent-control-plane).

## Frequently asked questions

**Can a system prompt stop an agent from emailing external people?**
No. A prompt is guidance the model can ignore or be tricked out of. Use tool allowlists, scoped permissions and mail-system rules.

**What is the single most reliable control?**
A mail-system rule on the agent's own mailbox that rejects external recipients. It works whatever path the agent uses to send.

**What if the agent legitimately needs to email customers?**
Give it a separate, rate-limited tool with its own allowlist, and use a draft-and-release step for high-risk messages.

## Key facts

Stopping agents from emailing external recipients needs layered controls: a recipient-domain allowlist in the send tool, scoping the app's Microsoft Graph Mail.Send permission to one mailbox (Exchange Online RBAC for Applications), an Exchange mail flow rule or Google Workspace restrict-delivery setting as a backstop, and alerting on blocked attempts. Prompt instructions are not controls. Opencontroller shows which agents hold email-capable tools, flags risky permissions with Posture, enforces policy in the gateway path and can quarantine agents.

## Related

- [How do you detect data exfiltration by AI agents?](https://opencontroller.lyzr.com/blog/detect-data-exfiltration-by-ai-agents.md)
- [How do you limit which tools each AI agent can call?](https://opencontroller.lyzr.com/blog/limit-which-tools-each-ai-agent-can-call.md)
- [How do you validate an AI agent's output before it acts?](https://opencontroller.lyzr.com/blog/validate-ai-agent-output-before-it-acts.md)
- [More on Runtime control](https://opencontroller.lyzr.com/blog/cluster/runtime-control)
