Securing AI Agents That Send Email
Secure AI email agents with recipient validation, draft vs send permissions, approval workflows, and sensitive-data checks before outbound mail.
AI email agent security requires treating outbound mail as a privileged side effect — not a formatting task. An agent that can send email is an exfiltration channel, a phishing vector, and a reputation risk. Secure email agents with recipient validation, draft-vs-send permissions, sensitive-data scanning, approval workflows for high-impact sends, and pre-execution policy checks before any message leaves your infrastructure.
Email tools combine two agent risks: data exfiltration (attach or paste secrets into body) and social engineering (send convincing phishing to customers). Policy and authorization must gate the send path independently of what the model drafted. See Prevent AI Agent Data Exfiltration for egress patterns that apply directly to mail tools.
Email agent threat model
| Threat | Example | Control |
|---|---|---|
| Exfiltration | Model emails customer DB dump to external address | Block/review + secret scanning |
| Phishing | Agent sends password-reset link to attacker domain | Recipient allowlist + link validation |
| Impersonation | From address spoofed or wrong tenant branding | Fixed From via tool layer, not model args |
| Injection-driven send | Web page says "email all users their SSN" | Action guard + untrusted source handling |
| Over-broadcast | BCC entire customer base | Rate limits + review on bulk recipients |
The model chooses recipients and body text; your runtime enforces who may receive mail and what content may leave.
Split draft and send permissions
Expose two tool actions with different policy posture:
| Action | Purpose | Default policy |
|---|---|---|
create_draft | Compose without delivery | Allow with logging |
send | Deliver message | Review or allowlist-only |
Draft tools let agents iterate on copy without immediate egress. Send tools require guard evaluation and often human approval for external or bulk recipients.
type EmailProposal = {
tool_name: "email";
action: "send" | "create_draft";
arguments: {
to: string[];
cc?: string[];
subject: string;
body: string;
};
context?: string;
};
Never let the model set SMTP credentials or raw From headers. The tool implementation supplies authenticated sending identity from tenant configuration.
Recipient validation
Validate recipients in tool code before calling the guard:
- Allowlist — only
@yourcompany.comor verified customer emails for support agents - Blocklist — free webmail for internal copilots handling confidential data
- Tenant scope — recipient must belong to requesting organization
- Normalize — parse and dedupe addresses; reject header injection in subject or to fields
- Bulk detection — more than N recipients → force
review
Policy rules can match tool_name: "email" + action: "send" while your code rejects malformed addresses.
Pre-execution policy with Agent Action Guard
Evaluate every send (not drafts, unless drafts leave the tenant):
curl -X POST https://www.identicapi.com/api/v1/security/agent-action \
-H "Authorization: Bearer idapi_test_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"tool_name": "email",
"action": "send",
"arguments": {
"to": ["customer@example.com"],
"subject": "Your invoice",
"body": "Please find details attached..."
},
"context": "Agent composed reply to billing inquiry",
"policy_id": "email_prod"
}'
Handle decisions explicitly:
async function sendEmail(proposal: EmailProposal, principal: User) {
if (!validateRecipients(proposal.arguments.to, principal.tenantId)) {
return { error: "Recipient not allowed" };
}
const guard = await evaluateAgentAction(proposal);
if (guard.decision === "block") {
return { error: `Send blocked: ${guard.policy_reason}` };
}
if (guard.decision === "review") {
return await approvalQueue.enqueue(proposal, guard);
}
if (!principal.can("email:send")) {
return { error: "Not authorized" };
}
return emailService.send(proposal.arguments);
}
Agent Action Guard does not replace authorization. A user without email:send must be denied even when policy returns allow.
Scanning body and attachments for secrets
Scan combined subject, body, and attachment text before send:
curl -X POST https://www.identicapi.com/api/v1/security/pii-secrets \
-H "Authorization: Bearer idapi_test_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"text": "Subject: API rotation\nBody: New key is sk-live-..."
}'
Block or review on unsafe or suspicious verdicts. The guard's built-in secret rules also inspect combined tool context on agent-action requests — use both layers for defense in depth.
Human approval for high-impact sends
Route to human-in-the-loop review when:
- First send to a new external domain in the session
- Bulk recipients or mailing-list patterns
- Financial or legal content templates
- Guard returns
review - User message followed untrusted web/RAG content
Approval UI should show rendered preview, full recipient list, and detected findings — not only the model's summary.
Link and attachment policy
- Links — warn or block unknown domains; do not let agents embed arbitrary redirect URLs in customer mail
- Attachments — size limits; virus scan at infrastructure layer; block executable types
- Generated attachments — if the agent exports CSV from database tools, treat as bulk data export (review)
Destructive or data-heavy operations that feed email content should follow Safe Destructive AI Agent Actions patterns.
Logging without leaking content
Log: message ID, recipients (hashed if needed), guard decision, policy_reason, approver ID, tenant ID. Avoid storing full body in centralized logs when it may contain PII. Retention policies should match GDPR and internal compliance requirements.
Custom policy examples
| Rule | Decision |
|---|---|
email + send + external domain in to | review |
email + send + secret finding | block |
email + create_draft | allow |
email + send + recipient count > 10 | review |
Align policy_id with agent policy design and test with fixture sends in CI.
Integration checklist
- Separate draft and send tool actions
- Fix From identity in tool layer; model cannot override SMTP auth
- Validate recipients against tenant allowlists
- Call Agent Action Guard before every send
- Scan body for PII and secrets
- Require approval for bulk and first-time external sends
- Enforce application authorization independently of guard
- Log metadata for forensics without storing sensitive bodies
Email agents are high-trust integrations. Treat every send as a policy-gated, authorization-checked egress event — because a manipulated model will otherwise treat your mail API as a convenient export path.
Frequently asked questions
Why split draft and send for email agents?
Draft tools let agents compose without immediate egress. Send tools trigger policy evaluation and often human approval before delivery.
Who controls the From address in agent email?
Your tool implementation — not the model. SMTP credentials and sender identity come from tenant configuration to prevent impersonation and credential exposure.
What email actions should route to review?
External recipients, bulk sends, first-time domains in a session, financial or legal templates, and any send where Agent Action Guard returns review.
Should I scan email body for secrets before send?
Yes. Scan subject, body, and attachment text with PII and secrets detection. Block or review on unsafe or suspicious verdicts before calling the mail API.
Does a policy allow decision mean anyone can send email?
No. Application authorization must still verify the principal holds email:send or equivalent permission. Guard and IAM are both required.
Related reading
- Human-in-the-Loop Approval for AI Agent Actions
When should AI agent actions require human approval? Learn approval boundaries for financial, destructive, and external …
- How to Prevent AI Agents from Sending Sensitive Data
Prevent AI agent data exfiltration with least privilege, destination validation, secret scanning, and action policies be…
- How to Design Safe Destructive Actions for AI Agents
Design safe destructive agent actions — deletion, cancellation, revocation — with preview, confirmation, authorization, …