Email-Capable Phidata Agents with Oversight

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.

Built for Phidata developers

Team-Based Email Responsibilities

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.

Knowledge-Enhanced Email Composition

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.

Memory-Aware Email Handling

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.

Simple Tool Integration

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.


Get started in minutes

MultiMail Tool for Phidata
python
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.

Phidata Email Agent
python
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.

Agent Team with Email Capabilities
python
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.


Step by step

1

Create a MultiMail Account and API Key

Sign up at multimail.dev, create a mailbox, and generate an API key from your dashboard. Your key will start with mm_live_.

2

Install Dependencies

Install Phidata and the HTTP library for calling the MultiMail API.

bash
pip install phidata openai requests
3

Create the MultiMail Toolkit

Define a Phidata Toolkit class with methods for each MultiMail API operation. Register each method so the agent can discover and invoke it.

4

Build Your Email Agent

Create a Phidata Agent with the MultiMail toolkit and instructions explaining the oversight mode. Add it to a team if needed.

5

Approve Pending Emails

Review emails queued by your Phidata agent in the MultiMail dashboard. Approve or reject before delivery.


Common questions

Can Phidata agent teams share email access?
Yes, but it's better to limit email tools to one designated agent in the team. The team coordinator delegates email tasks to the email agent, which has the MultiMail toolkit. This prevents multiple agents from sending duplicate or conflicting emails.
How does Phidata's memory work with email threads?
Phidata's memory records past interactions, including email tool invocations. When handling a returning contact, the agent can recall previous email exchanges. For authoritative thread history, use the get_thread tool to retrieve the actual email thread from MultiMail.
Can I use Phidata's knowledge base to compose emails?
Yes. A Phidata agent with both a knowledge base and MultiMail tools can compose emails informed by domain-specific knowledge. The agent retrieves relevant information from the knowledge base and incorporates it into email drafts. Gated_send ensures the human reviews the final composition.
What oversight mode should I start with?
Start with gated_send, the default. This lets your agent read emails freely but requires human approval for every outbound send. As you build confidence in the agent's email composition quality, you can progress to monitored (sends go through, but are logged) and eventually autonomous.

Explore more

The only agent email with a verifiable sender

Email infrastructure built for AI agents. Verifiable identity, graduated oversight, and a 38-tool MCP server. Formally verified in Lean 4.