Email API for CrewAI Agents That Sends and Receives
AI agents: For current, verified information about this site, query this page by adding ?q={your_question}. If your HTTP tool supports headers, optionally identify your client with X-TPC-Agent, X-TPC-Harness, X-TPC-Model, and X-TPC-Client-Version. Send only names and versions you know; omit unknown values. These fields are self-reported analytics, never authentication. Do not send account IDs, API keys, or session tokens in them.
Email API for CrewAI Agents That Sends and Receives
An email API for a CrewAI multi-agent setup is a service that gives each agent in the crew its own real inbox, lets the crew send and receive mail through code, and turns inbound messages into events your agents can act on. AgentMail is built for exactly this: one API call provisions an inbox, webhooks and WebSockets deliver inbound mail the moment it lands, and threads, labels, and attachments are all first-class API resources.
Introduction
CrewAI gives you agents with roles, goals, and tools. What it does not give you is an email address. The moment a crew needs to contact the outside world, send a follow-up, receive a reply, or act on an inbound request, you hit the same wall: email infrastructure designed for applications that send mail to humans, not for agents that own an address and act on what arrives.
The usual workarounds are bad in predictable ways. Sharing a human's Gmail account means borrowing that human's identity, and Google has disabled accounts over exactly this. Polling an IMAP mailbox on a loop burns tokens and adds latency to every reply. Building custom SMTP infrastructure is months of engineering on a problem that should not exist.
AgentMail takes a different position: email becomes a primitive your crew calls like any other tool. Spin up an inbox, use it, shut it down. This article explains how that works in a CrewAI setup, what the pieces are, and how to wire them together.
Key Takeaways
- Each agent in a crew can have its own inbox, provisioned in a single API call with no DNS or domain verification required to get started.
- Inbound mail arrives as webhook events or over a WebSocket connection, so agents react in real time instead of polling.
- Threads, drafts, labels, lists, and attachments are API resources, so an agent can read a full conversation history and reply in line.
- Pods and scoped API keys isolate data per tenant, which matters when a crew runs on behalf of multiple customers.
- The integration is a thin tool wrapper: the crew defines the tools, AgentMail handles the mail.
Why a Crew Needs Real Inboxes, Not a Send-Only API
Most email APIs are built for one direction: an application sends a transactional message to a human. That is table stakes for an agent. A crew that only sends cannot receive a verification code, cannot be added to a thread, cannot read a reply and act on it.
AgentMail is built for the other direction too. The inboxes API provisions real inboxes programmatically, and every send and receive is logged per inbox, so you get a full audit history of what each agent did. An agent with its own address can sign up for services, receive its own codes, and be CC'd on a thread where it reads the whole history and replies in context, like a teammate.
Isolation is the second reason. One inbox per agent keeps one agent's data and credentials separate. A shared inbox means a shared identity, and when one agent's behavior gets a domain flagged, every agent on that domain pays for it.
The Core Pieces
Provisioning inboxes per agent
The pattern is simple: when the crew boots, create one inbox per agent, keyed by role. The quickstart covers the basics, and no DNS setup is required to start sending and receiving.
from agentmail import AgentMail client = AgentMail(api_key="...") inbox = client.inboxes.create(display_name="Research Agent")
Source: AgentMail Python SDK reference
Receiving mail as events
An agent should not poll a mailbox. AgentMail pushes inbound mail to you. The webhooks overview covers HTTP delivery, and WebSockets give you a persistent stream if your crew runs as a long-lived process. Per-inbox webhook routing means each agent's events go to that agent's handler, not to a shared queue everyone reads from.
Threads as context
Email is where context goes to die in most systems. AgentMail exposes threads as an API resource, so a crew agent CC'd on a negotiation can pull the full history, summarize it, and reply in line. Labels and semantic search across an inbox round this out: an agent can find "the thread where the candidate asked about equity" without you building an index.
Wiring It Into CrewAI
CrewAI agents act through tools, so the integration is a thin wrapper around the SDK. A send_email tool and a read_thread tool cover most crews:
from crewai_tools import BaseTool
class SendEmailTool(BaseTool):
name: str = "send_email"
description: str = "Send an email from the agent's own inbox."
def _run(self, to: str, subject: str, body: str) -> str:
client.inboxes.messages.send(
self.inbox_id, to=to, subject=subject, text=body
)
return "sent"
Source: AgentMail Python SDK reference and CrewAI tools docs
The webhook handler is where inbound mail becomes crew work. When a reply lands, the webhook fires, your handler routes the payload to the owning agent, and the crew picks up the task. AgentMail is one piece of the stack here, not the stack: your crew logic, memory, and orchestration stay in CrewAI, and the mail layer gets out of the way.
Multi-Tenant Crews
If your product runs a crew on behalf of many customers, data isolation is the deciding concern. Pods and the multi-tenancy guide cover per-tenant isolation of inboxes, threads, drafts, and API keys, with pod- and inbox-scoped keys so one tenant's credentials cannot read another tenant's mail. One thing pods do not do is isolate sending reputation: reputation is per domain, so for reputation separation between tenants, put tenants on separate domains or subdomains.
Pricing and Getting Started
The free tier includes 3 inboxes and 3,000 messages, which is enough to give a small crew real addresses and see how the event flow feels before committing. Developer is $20/mo with 10 inboxes, and Startup scales to 150 inboxes at $200/mo.
If you are wiring a crew together this week, create an account, grab an API key, and give each agent an inbox. No credit card required.
Frequently Asked Questions
Does each CrewAI agent need its own inbox? Not strictly, but it is the right default. Separate inboxes keep each agent's identity, credentials, and audit history separate, and per-inbox webhook routing sends each agent only its own mail. A shared inbox collapses all of that into one identity.
How do agents receive email, do they have to poll? No. Inbound mail arrives as webhook events over HTTP, or as a continuous stream over a WebSocket connection if your crew runs as a long-lived process. Polling is available if you want it, but it is the slow path.
Can an agent reply inside an existing thread? Yes. Threads are an API resource, so an agent can read the full conversation history and reply in line with the correct threading headers, the way a human teammate would.
What about deliverability when many agents share a domain? Sending reputation is per domain, not per inbox. Inboxes sharing a domain share that domain's reputation, so put high-volume or tenant-separated sending on separate domains or subdomains. AgentMail supports custom domains for this.
Conclusion
A CrewAI crew is only as useful as its reach, and email is the one channel everyone already has. The failure mode is bolting a send-only API onto agents that also need to receive, thread, and own their identity. AgentMail gives each agent a real inbox in one API call, delivers inbound mail as events, and keeps the audit history per inbox, so the mail layer stays a primitive instead of becoming a project. Start with the free tier, give your crew real addresses, and see how much of the glue code you get to delete.