Connect Azure AI's managed model deployments to MultiMail for sending, reading, and managing email — with enterprise content safety and human oversight.
Azure AI provides enterprise-grade access to OpenAI models and other foundation models with managed deployments, content safety, and governance features. MultiMail gives Azure AI agents the email infrastructure they need to send, receive, and manage email while meeting enterprise compliance requirements.
By integrating MultiMail with Azure AI, enterprises get comprehensive audit trails and governance for AI-initiated email. Azure's content safety handles model-level filtering, MultiMail's oversight modes handle send authorization, and both produce audit logs for compliance. The default gated_send mode means your agent drafts emails but a human approves before delivery.
Connect Azure AI to MultiMail by defining email functions using Azure OpenAI's function calling format and routing calls to the MultiMail REST API. The API is compatible with OpenAI's format, making integration straightforward.
Azure AI's managed deployments demand auditability. MultiMail's comprehensive audit logs and approval workflows align with enterprise governance requirements for AI-initiated communications.
Azure's content safety filters harmful content at the model level. MultiMail adds email-specific oversight on top, creating defense-in-depth that enterprise security teams require.
MultiMail works with Azure OpenAI's managed endpoints. Your existing Azure deployment handles inference while MultiMail handles email delivery, oversight, and compliance.
Start with gated_send (agent composes, human approves) and progress to autonomous as trust builds. MultiMail's oversight modes align with enterprise change management processes for AI capabilities.
MultiMail logs every email action with timestamps, actor identity, and approval status. Combined with Azure Monitor and Log Analytics, you get end-to-end traceability for regulatory compliance.
from azure.ai.inference import ChatCompletionsClient
from azure.ai.inference.models import (
SystemMessage, UserMessage, AssistantMessage, ToolMessage,
ChatCompletionsToolDefinition, FunctionDefinition
)
from azure.core.credentials import AzureKeyCredential
import requests
import json
client = ChatCompletionsClient(
endpoint="https://your-resource.openai.azure.com",
credential=AzureKeyCredential("your_azure_api_key")
)
MULTIMAIL_API = "https://api.multimail.dev/v1"
MM_HEADERS = {"Authorization": "Bearer mm_live_your_api_key"}
email_tools = [
ChatCompletionsToolDefinition(
function=FunctionDefinition(
name="send_email",
description="Send an email through MultiMail. In gated_send mode, queues for approval.",
parameters={
"type": "object",
"properties": {
"mailbox_id": {"type": "string", "description": "Mailbox to send from"},
"to": {"type": "string", "description": "Recipient email"},
"subject": {"type": "string", "description": "Subject line"},
"body": {"type": "string", "description": "Email body"}
},
"required": ["mailbox_id", "to", "subject", "body"]
}
)
),
ChatCompletionsToolDefinition(
function=FunctionDefinition(
name="check_inbox",
description="Check inbox for recent messages.",
parameters={
"type": "object",
"properties": {
"mailbox_id": {"type": "string", "description": "Mailbox to check"},
"limit": {"type": "integer", "description": "Max messages"}
},
"required": ["mailbox_id"]
}
)
)
]Create function definitions using Azure OpenAI's function calling format for email tools.
def execute_tool(name, args):
if name == "send_email":
resp = requests.post(f"{MULTIMAIL_API}/send", headers=MM_HEADERS, json=args)
elif name == "check_inbox":
resp = requests.get(
f"{MULTIMAIL_API}/mailboxes/{args[&"cm">#039;mailbox_id']}/inbox",
headers=MM_HEADERS, params={"limit": args.get("limit", 10)}
)
elif name == "reply_email":
resp = requests.post(f"{MULTIMAIL_API}/reply", headers=MM_HEADERS, json=args)
else:
return {"error": f"Unknown tool: {name}"}
return resp.json()
def run_azure_email_agent(user_message, mailbox_id):
messages = [
SystemMessage(content=f"You are an email assistant for mailbox {mailbox_id}. "
f"Emails use gated_send mode and queue for human approval."),
UserMessage(content=user_message)
]
while True:
response = client.complete(
model="gpt-4o",
messages=messages,
tools=email_tools
)
msg = response.choices[0].message
if msg.tool_calls:
messages.append(AssistantMessage(tool_calls=msg.tool_calls))
for tc in msg.tool_calls:
result = execute_tool(
tc.function.name,
json.loads(tc.function.arguments)
)
messages.append(ToolMessage(
tool_call_id=tc.id,
content=json.dumps(result)
))
else:
return msg.content
print(run_azure_email_agent("Check my inbox", "mbx_abc123"))Create an agentic loop using Azure AI's chat completions with MultiMail tools.
from openai import AzureOpenAI
import json
client = AzureOpenAI(
azure_endpoint="https://your-resource.openai.azure.com",
api_key="your_azure_api_key",
api_version="2024-10-21"
)
"cm"># Same tool format as OpenAI
email_functions = [
{
"type": "function",
"function": {
"name": "send_email",
"description": "Send an email. In gated_send mode, queues for approval.",
"parameters": {
"type": "object",
"properties": {
"mailbox_id": {"type": "string"},
"to": {"type": "string"},
"subject": {"type": "string"},
"body": {"type": "string"}
},
"required": ["mailbox_id", "to", "subject", "body"]
}
}
}
]
response = client.chat.completions.create(
model="gpt-4o", "cm"># Your Azure deployment name
messages=[
{"role": "system", "content": "Email assistant. gated_send mode."},
{"role": "user", "content": "Send a meeting reminder to [email protected]"}
],
tools=email_functions
)Use the Azure OpenAI Python SDK for a more familiar API if migrating from OpenAI.
Sign up at multimail.dev, create a mailbox, and generate an API key. Store it in Azure Key Vault for secure access from your application.
Install the Azure AI Inference SDK or Azure OpenAI SDK, plus requests for calling the MultiMail API.
pip install azure-ai-inference requestsDeploy GPT-4o or another model with function calling support in your Azure AI resource. Note the endpoint URL and deployment name.
Implement a loop that sends messages to Azure AI, checks for tool calls, executes tools against MultiMail, and returns results.
response = client.complete(
model="gpt-4o",
messages=messages,
tools=email_tools
)If your mailbox uses gated_send mode (the default), review and approve pending emails in the MultiMail dashboard before they are delivered.
Email infrastructure built for AI agents. Verifiable identity, graduated oversight, and a 38-tool MCP server. Formally verified in Lean 4.