E2B sandboxes prevent code execution damage — MultiMail adds the email-specific safety layer that catches sends from within the sandbox.
E2B provides secure sandboxed environments (isolated micro-VMs) where AI agents execute code safely. While E2B prevents filesystem and process-level damage, sandboxed code can still make network calls to email APIs. MultiMail adds an email-specific safety layer that complements E2B's execution isolation.
With MultiMail's gated_send mode, even code running inside an E2B sandbox must have its emails approved by a human before delivery. This defense-in-depth approach means E2B handles code execution safety while MultiMail handles email delivery safety.
Integration is straightforward: install the requests library in the E2B sandbox and call the MultiMail REST API from your sandboxed code. MultiMail's oversight is enforced server-side, so the sandbox cannot bypass it.
E2B sandboxes prevent code damage but can't stop outbound API calls. MultiMail adds an email-specific gate at the API level, ensuring sandboxed code can't send unauthorized emails.
MultiMail's oversight is enforced on MultiMail's servers, not in the sandbox. Even if sandbox code tries to bypass client-side checks, the API refuses to deliver emails without approval in gated_send mode.
MultiMail's REST API works from any environment that can make HTTPS calls. No special SDKs or native dependencies needed — just standard HTTP requests from within the E2B sandbox.
If sandboxed code enters a loop calling the email API, MultiMail's plan-level rate limits prevent excessive sends. Combined with gated_send, this provides multiple safety layers.
from e2b_code_interpreter import Sandbox
sandbox = Sandbox()
"cm"># Install requests in the sandbox
sandbox.commands.run("pip install requests")
"cm"># Execute email code inside the sandbox
execution = sandbox.run_code("""
import requests
MULTIMAIL_API = "https://api.multimail.dev/v1"
HEADERS = {"Authorization": "Bearer mm_live_your_api_key"}
# Send email — gated_send mode queues for approval
resp = requests.post(f"{MULTIMAIL_API}/send", headers=HEADERS, json={
"mailbox_id": "your_mailbox_id",
"to": "[email protected]",
"subject": "Report from sandbox",
"body": "This email was composed by an agent running in an E2B sandbox."
})
result = resp.json()
print(f"Status: {result.get(&"cm">#039;status')}")
print(f"Email queued for approval: {result.get(&"cm">#039;id')}")
""")
print(execution.text)
sandbox.kill()Execute email-sending code inside an E2B sandbox with MultiMail oversight.
from e2b_code_interpreter import Sandbox
sandbox = Sandbox()
sandbox.commands.run("pip install requests")
execution = sandbox.run_code("""
import requests
import json
MULTIMAIL_API = "https://api.multimail.dev/v1"
HEADERS = {"Authorization": "Bearer mm_live_your_api_key"}
MAILBOX_ID = "your_mailbox_id"
# Check inbox
resp = requests.get(
f"{MULTIMAIL_API}/mailboxes/{MAILBOX_ID}/inbox",
headers=HEADERS,
params={"limit": 5}
)
inbox = resp.json()
for msg in inbox.get("messages", []):
print(f"From: {msg[&"cm">#039;from']}")
print(f"Subject: {msg[&"cm">#039;subject']}")
print(f"Date: {msg[&"cm">#039;date']}")
print("---")
""")
print(execution.text)
sandbox.kill()Read emails from within an E2B sandbox for agent processing.
from e2b_code_interpreter import Sandbox
from openai import OpenAI
client = OpenAI()
sandbox = Sandbox()
sandbox.commands.run("pip install requests")
"cm"># LLM generates email processing code
response = client.chat.completions.create(
model="gpt-4o",
messages=[{
"role": "system",
"content": (
"Generate Python code that uses the MultiMail API "
"to check the inbox and draft replies to unread "
"messages. API base: https://api.multimail.dev/v1, "
"auth: Bearer mm_live_your_api_key, "
"mailbox: your_mailbox_id. "
"All sends use gated_send mode (queued for approval)."
)
}, {
"role": "user",
"content": "Check inbox, summarize messages, reply to urgent ones"
}]
)
generated_code = response.choices[0].message.content
"cm"># Execute the LLM-generated code safely in E2B sandbox
"cm"># MultiMail's API-level oversight catches any email sends
execution = sandbox.run_code(generated_code)
print(execution.text)
sandbox.kill()Let an LLM agent generate and run email processing code inside a sandboxed environment.
Sign up at multimail.dev, create a mailbox, and generate an API key from your dashboard. Your key will start with mm_live_.
Install the E2B code interpreter SDK.
pip install e2b-code-interpreterCreate an E2B sandbox and install the requests library for making MultiMail API calls.
sandbox = Sandbox()
sandbox.commands.run(&"cm">#039;pip install requests')Run code that calls the MultiMail API from within the sandbox. The API key authenticates the request, and gated_send mode ensures oversight.
Review emails queued by sandbox code 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.