Give Phidata agents full email capabilities through MultiMail — with graduated trust modes that let you start with human approval and progress to autonomous.
Phidata is a framework for building AI agents with memory, knowledge, and tools. Its agent teams can include specialists for different tasks — research, analysis, communication. MultiMail provides the email tool layer for communication agents, with oversight modes that match Phidata's philosophy of building trustworthy AI systems.
By integrating MultiMail as a Phidata tool, your agents can send emails, check inboxes, manage contacts, and track threads. The default gated_send mode means the email agent in your team drafts messages but a human approves before delivery, building trust incrementally.
Integration is simple: define a custom Phidata tool class that wraps MultiMail REST API calls, then assign it to any agent that needs email capabilities.
Phidata's agent teams can include a dedicated email agent alongside research and analysis agents. MultiMail provides the email infrastructure while oversight modes ensure the email agent can't send without authorization.
Phidata agents with knowledge bases can compose emails informed by domain-specific context. MultiMail handles delivery with oversight, ensuring knowledge-driven emails are reviewed before reaching recipients.
Phidata's memory features let agents recall past interactions. Combined with MultiMail's thread tracking, agents can draft replies that reference both their memory and the actual email thread history.
Phidata's tool system maps directly to MultiMail's API. Define a tool class with methods for each email operation, and the agent can invoke them naturally during conversations.
import requests
from phi.tools import Toolkit
class MultiMailTools(Toolkit):
def __init__(self, api_key: str, mailbox_id: str):
super().__init__(name="multimail")
self.api_key = api_key
self.mailbox_id = mailbox_id
self.base_url = "https://api.multimail.dev/v1"
self.headers = {"Authorization": f"Bearer {api_key}"}
self.register(self.send_email)
self.register(self.check_inbox)
self.register(self.reply_email)
self.register(self.get_thread)
def send_email(self, to: str, subject: str, body: str) -> str:
"""Send an email. In gated_send mode, queues for approval."""
resp = requests.post(f"{self.base_url}/send",
headers=self.headers,
json={"mailbox_id": self.mailbox_id,
"to": to, "subject": subject,
"body": body})
return str(resp.json())
def check_inbox(self, limit: int = 10) -> str:
"""Check inbox for recent messages."""
resp = requests.get(
f"{self.base_url}/mailboxes/{self.mailbox_id}/inbox",
headers=self.headers, params={"limit": limit})
return str(resp.json())
def reply_email(self, message_id: str, body: str) -> str:
"""Reply to an email within its thread."""
resp = requests.post(f"{self.base_url}/reply",
headers=self.headers,
json={"message_id": message_id,
"body": body})
return str(resp.json())
def get_thread(self, thread_id: str) -> str:
"""Get all messages in an email thread."""
resp = requests.get(f"{self.base_url}/threads/{thread_id}",
headers=self.headers)
return str(resp.json())Create a custom Phidata tool that wraps MultiMail API calls.
from phi.agent import Agent
from phi.model.openai import OpenAIChat
email_tools = MultiMailTools(
api_key="mm_live_your_api_key",
mailbox_id="your_mailbox_id"
)
email_agent = Agent(
name="Email Agent",
model=OpenAIChat(id="gpt-4o"),
tools=[email_tools],
description="You handle email communications via MultiMail.",
instructions=[
"Use MultiMail tools to send, read, and reply to emails.",
"All outbound emails use gated_send mode — they are queued "
"for human approval before delivery.",
"When checking inbox, summarize messages concisely.",
"When replying, maintain professional tone and reference "
"the original message context."
],
show_tool_calls=True,
markdown=True
)
"cm"># Run the agent
email_agent.print_response(
"Check my inbox and summarize any unread messages"
)Create a Phidata agent with MultiMail email tools and memory.
from phi.agent import Agent
from phi.model.openai import OpenAIChat
"cm"># Research agent (no email access)
research_agent = Agent(
name="Research Agent",
model=OpenAIChat(id="gpt-4o"),
description="You research topics and provide detailed analysis.",
instructions=["Provide thorough, factual research summaries."]
)
"cm"># Email agent (with MultiMail access)
email_agent = Agent(
name="Email Agent",
model=OpenAIChat(id="gpt-4o"),
tools=[MultiMailTools(
api_key="mm_live_your_api_key",
mailbox_id="your_mailbox_id"
)],
description="You handle all email communications.",
instructions=[
"Send emails based on research findings from the team.",
"All emails use gated_send mode (queued for approval)."
]
)
"cm"># Team coordinator
team = Agent(
name="Team Lead",
model=OpenAIChat(id="gpt-4o"),
team=[research_agent, email_agent],
instructions=[
"Coordinate research and email tasks.",
"Use the research agent for gathering information.",
"Use the email agent for sending communications."
]
)
team.print_response(
"Research the latest AI safety guidelines and email "
"a summary to [email protected]"
)Build a Phidata agent team where one agent handles research and another handles email communication.
Sign up at multimail.dev, create a mailbox, and generate an API key from your dashboard. Your key will start with mm_live_.
Install Phidata and the HTTP library for calling the MultiMail API.
pip install phidata openai requestsDefine a Phidata Toolkit class with methods for each MultiMail API operation. Register each method so the agent can discover and invoke it.
Create a Phidata Agent with the MultiMail toolkit and instructions explaining the oversight mode. Add it to a team if needed.
Review emails queued by your Phidata agent in the MultiMail dashboard. Approve or reject before delivery.
Email infrastructure built for AI agents. Verifiable identity, graduated oversight, and a 38-tool MCP server. Formally verified in Lean 4.