Give Your GPT-4 Agents Email Capabilities

Use OpenAI's function calling to connect GPT-4 agents to MultiMail for sending, reading, and managing email with configurable human oversight.


OpenAI's API provides function calling capabilities that let GPT-4 and other models invoke external tools with structured arguments. MultiMail gives these models a complete email infrastructure layer, so your agents can send, receive, read, and reply to emails on behalf of users through well-defined function calls.

By integrating MultiMail with the OpenAI API, your agents can handle email workflows while respecting human oversight boundaries. The default gated_send mode means your GPT-4 agent drafts emails but a human approves before delivery, adding a critical safety layer that the OpenAI API itself does not provide for external tool execution.

Connect OpenAI to MultiMail by defining email functions in OpenAI's function calling format and routing calls to the MultiMail REST API. You can also use the @multimail/mcp-server for automatic tool discovery with compatible adapters.

Built for OpenAI API developers

Function Calling Compatibility

OpenAI's function calling uses JSON Schema definitions that map directly to MultiMail's API endpoints. Define send_email, check_inbox, and reply_email as functions, and GPT-4 generates structured calls with typed parameters.

Safety Layer for Autonomous Agents

OpenAI's API does not gate external tool execution. MultiMail's oversight modes add the missing safety layer — from gated_send (human approves every email) to autonomous (full agent control) — so you can deploy email agents with confidence.

Assistants API Compatible

MultiMail works with both the Chat Completions API and the Assistants API. Define email functions as tools in either API, and your agent can manage email as part of broader multi-tool workflows.

Thread and Contact Management

MultiMail tracks email threads and contacts automatically. Your OpenAI agent can retrieve conversation context with get_thread and manage relationships with manage_contacts, enabling sophisticated email workflows.

MCP Server Integration

The @multimail/mcp-server package exposes email tools in the Model Context Protocol format. Use MCP adapters to automatically discover and register all MultiMail tools with your OpenAI-powered agent.


Try it with your agent

No code, no dashboard. Paste this to your AI agent — it connects MultiMail, creates an inbox, and builds the flow for you.

1. Get MultiMail ready before you run me: read https://multimail.dev/llms.txt, connect the MultiMail MCP server in your agent environment, create a free inbox, and set up a verified sending domain. Use gated_send as the oversight mode so every outgoing message requires developer review before it is sent. 2. Wire MultiMail into the OpenAI API agent with OpenAI function calling: expose three function tools from your application to the model, named check_inbox, draft_reply, and send_email. Implement those functions by calling the connected MultiMail MCP server for reading inbox mail, composing replies, and sending or scheduling email. Do not let the model send email directly outside those functions. 3. Give me these operating rules: use check_inbox to read recent messages, use draft_reply to prepare a response with recipient, subject, body, and rationale, and use send_email only after the developer approves the draft. Keep oversight mode set to gated_send; do not switch to monitored or autonomous during testing. 4. Send a test email: ask me to draft a short test message from the verified sender to a developer-controlled address, then show the full draft for review. After approval, call send_email through the OpenAI function tool and the MultiMail MCP server. 5. Confirm the gated flow worked: verify that I requested approval before sending, that the final message used the verified sender and free inbox, and that future inbox checks, draft replies, sends, and scheduled sends all continue through the same OpenAI function-calling tools backed by MultiMail MCP.

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 the OpenAI Python SDK and requests library for calling the MultiMail API.

3

Define Email Function Schemas

Create function definitions for send_email, check_inbox, and other MultiMail operations using OpenAI's tools format with JSON Schema parameters.

4

Build the Agent Loop

Implement a loop that sends messages to GPT-4, checks for tool_calls in the response, executes functions against MultiMail, and returns results as tool messages.

5

Approve Pending Emails

If your mailbox uses gated_send mode (the default), review and approve pending emails in the MultiMail dashboard before they are delivered.


Common questions

Can I use the Assistants API with MultiMail?
Yes. Define MultiMail email functions as tools when creating your Assistant. The Assistants API manages conversation state and tool execution, so you can build persistent email agents that remember context across sessions. Define the same function schemas used with Chat Completions.
What happens when GPT-4 sends an email in gated_send mode?
In gated_send mode, the MultiMail API returns a success response with a pending status. The email is queued for human review in the MultiMail dashboard. Once approved, it is delivered. Your agent can check the status of pending emails using the list_pending endpoint.
Does GPT-4 support parallel email function calls?
Yes. GPT-4 can return multiple tool_calls in a single response. For example, it might call check_inbox and manage_contacts simultaneously. Your execution loop should handle all tool calls and return all results before the next model invocation.
How do I handle email attachments?
The MultiMail API supports attachments via the send and reply endpoints. Pass attachments as base64-encoded content in the request body. Your function definition should include an optional attachments parameter that GPT-4 can populate when the user requests it.
Is there rate limiting on the MultiMail API?
Rate limits depend on your plan tier. The Starter (free) plan allows 200 emails per month, while paid plans range from 5,000 to 150,000. The API returns standard 429 responses when limits are reached, which your agent loop can handle with retry logic.

Explore more

The only agent email with a verifiable sender

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