Transactional Email Infrastructure for AI Agents

Send order confirmations, receipts, and account notifications through AI agents at scale — with built-in CAN-SPAM compliance, DKIM signing, and delivery tracking.


Why this matters

Transactional emails — order confirmations, receipts, billing notifications, account alerts — need to reach inboxes reliably and comply with CAN-SPAM. When AI agents generate and send these emails, you need infrastructure that handles deliverability, identity authentication, and compliance automatically. Rolling your own SMTP pipeline means managing DKIM keys, handling bounces, maintaining sender reputation, and staying current with CAN-SPAM rules — all while ensuring your agent's output is accurate enough to send without manual review on every message.


How MultiMail solves this

MultiMail provides a single API that AI agents use to send transactional email with production-grade deliverability. DKIM signing, SPF alignment, bounce suppression, and CAN-SPAM footer compliance are built into the infrastructure — agents don't implement them. The monitored oversight mode lets agents send autonomously while giving your operations team a complete log of every message dispatched. Webhooks deliver real-time delivery, bounce, and complaint events back to your agent so it can update downstream systems without polling.

1

Trigger Event

A business event — order placed, payment received, account created — triggers your agent. The agent receives structured data: order ID, customer email, line items, or account details, and proceeds to compose the transactional message.

2

Generate and Send

The agent calls send_email via the REST API, Python SDK, or MCP tool. MultiMail validates the payload, applies DKIM signing to the sending domain, enforces CAN-SPAM header requirements, and queues the message for delivery.

3

Track Delivery

MultiMail emits webhook events for delivered, bounced, deferred, and complained statuses. Metadata you attached at send time — order_id, user_id, event type — is included in every event payload so you can correlate delivery outcomes with business records.

4

Handle Bounces

Hard bounces are automatically suppressed at the infrastructure layer to protect sender reputation. Your webhook handler receives the bounce type and recipient address so downstream systems — CRM, order management — can be updated with accurate delivery status.

5

Monitor with Oversight

In monitored mode, every outbound transactional message is logged and visible to your team in real time. No approval gate delays delivery, but operators can review the full message history and intervene if the agent produces incorrect content — wrong totals, wrong recipient.


Implementation

Send an Order Confirmation via Python SDK
python
from multimail import MultimailClient

client = MultimailClient(api_key="mm_live_...")

def send_order_confirmation(order: dict) -> dict:
    response = client.send_email(
        from_mailbox="[email protected]",
        to=order["customer_email"],
        subject=f"Order "cm">#{order['id']} confirmed",
        body=(
            f"Hi {order[&"cm">#039;customer_name']},\n\n"
            f"Your order has been confirmed and will ship within 2 business days.\n\n"
            f"Order total: ${order[&"cm">#039;total']:.2f}\n"
            f"Items: {&"cm">#039;, '.join(i['name'] for i in order['items'])}\n\n"
            f"Track your order at https://acmecorp.com/orders/{order[&"cm">#039;id']}"
        ),
        metadata={"order_id": order["id"], "event": "order_confirmed"}
    )
    return response

Send a transactional email from an AI agent using multimail-sdk. The SDK handles auth, retries, and surfaces delivery errors as exceptions.

Send via REST API
bash
curl -X POST https://api.multimail.dev/v1/emails/send \
  -H "Authorization: Bearer $MULTIMAIL_API_KEY..." \
  -H "Content-Type: application/json" \
  -d &"cm">#039;{
    "from": "[email protected]",
    "to": "[email protected]",
    "subject": "Order #4821 confirmed",
    "body": "Your order has been confirmed and will ship within 2 business days. Order total: $142.00.",
    "metadata": {
      "order_id": "4821",
      "event": "order_confirmed"
    }
  }&"cm">#039;

Direct REST API call to send_email. Use when your agent runs in an environment without the Python SDK installed.

Webhook Handler for Delivery and Bounce Events
python
from flask import Flask, request, jsonify

app = Flask(__name__)

@app.route("/webhooks/multimail", methods=["POST"])
def handle_delivery_event():
    event = request.get_json()
    event_type = event.get("type")
    metadata = event.get("metadata", {})

    if event_type == "email.delivered":
        order_id = metadata.get("order_id")
        mark_confirmation_sent(order_id)

    elif event_type == "email.bounced":
        order_id = metadata.get("order_id")
        recipient = event.get("to")
        bounce_type = event.get("bounce_type")  "cm"># "hard" or "soft"
        if bounce_type == "hard":
            flag_invalid_address(recipient, order_id)

    elif event_type == "email.complained":
        "cm"># CAN-SPAM: honor opt-outs within 10 business days
        recipient = event.get("to")
        unsubscribe_recipient(recipient)

    return jsonify({"ok": True})

def mark_confirmation_sent(order_id: str): ...
def flag_invalid_address(email: str, order_id: str): ...
def unsubscribe_recipient(email: str): ...

Handle delivery status webhooks so your agent can update downstream systems. MultiMail suppresses hard bounces automatically, but your system needs to record which addresses failed.

Send via MCP Tool (Claude Desktop / Cursor)
json
{
  "tool": "send_email",
  "parameters": {
    "from": "[email protected]",
    "to": "[email protected]",
    "subject": "Your account has been verified",
    "body": "Your acmecorp.com account is now active. You can log in at https://acmecorp.com/login.\n\nIf you did not create this account, reply to this email immediately.",
    "metadata": {
      "event": "account_verified",
      "user_id": "usr_8821"
    }
  }
}

Call the send_email MCP tool directly from a Claude Desktop or Cursor session when an agent needs to dispatch a transactional email as part of a longer workflow.

LangChain Agent Sending Order Receipts
python
from langchain.tools import tool
from multimail import MultimailClient

client = MultimailClient(api_key="mm_live_...")

@tool
def send_order_receipt(order_id: str, customer_email: str, total: float) -> str:
    """Send a purchase receipt to the customer after checkout completes."""
    response = client.send_email(
        from_mailbox="[email protected]",
        to=customer_email,
        subject=f"Receipt for order #{order_id}",
        body=(
            f"Thank you for your purchase.\n\n"
            f"Order: #{order_id}\n"
            f"Total charged: ${total:.2f}\n\n"
            f"Questions? Reply to this email or visit https://acmecorp.com/support"
        ),
        metadata={"order_id": order_id, "event": "receipt_sent"}
    )
    return f"Receipt sent. Message ID: {response[&"cm">#039;message_id']}"

"cm"># Add send_order_receipt to your agent's tool list

Wire MultiMail's send_email into a LangChain agent as a tool so the agent can dispatch transactional emails mid-chain without leaving the framework.


What you get

CAN-SPAM Compliance at the Infrastructure Layer

MultiMail enforces CAN-SPAM requirements automatically: physical mailing address in the footer, accurate from-address, working unsubscribe mechanism, and compliant headers. Transactional emails have narrower obligations than marketing email, but MultiMail handles both. Agents do not implement compliance logic — it is enforced on every send.

DKIM and SPF Identity Signing

Every email sent through MultiMail is signed with DKIM and aligned with your domain's SPF record. When you provision a custom-domain mailbox, MultiMail generates the DKIM keypair and provides DNS records to publish. After propagation, signing is automatic on every outbound message — no agent-side key management.

Real-Time Delivery Webhooks with Metadata Passthrough

MultiMail delivers structured webhook events for delivered, bounced, deferred, and complained statuses. Metadata you attached at send time — order_id, user_id, event type — is echoed in every event payload, so your downstream systems stay accurate without maintaining a separate message-to-record mapping table.

Automatic Bounce Suppression

Hard-bounced addresses are automatically suppressed from future sends at the infrastructure layer, protecting your domain's sender reputation without any agent-side logic. Bounce details — type, recipient, send metadata — are available via webhook for your CRM or customer database.

Operator Visibility Without Delivery Gates

Monitored mode gives operations teams a complete audit log of every transactional email sent by your agents, with full message content and metadata. Delivery is not gated — confirmations reach customers in under a second — but operators can identify and remediate incorrect agent output without waiting for a customer complaint.


Recommended oversight mode

Recommended
monitored
Transactional emails are time-sensitive — order confirmations and account alerts must reach customers within seconds of the triggering event. Approval gates (gated_send or gated_all) introduce latency that is unacceptable for high-volume transactional flows in SaaS, e-commerce, and finance. Monitored mode preserves autonomous delivery speed while giving operators complete visibility into every message sent. If an agent produces an incorrect transactional message — wrong order total, wrong recipient — the audit log enables fast identification and remediation without blocking the queue. For higher-stakes transactional emails in regulated contexts (e.g., wire transfer confirmations), consider gated_send where per-message latency is acceptable in exchange for human verification.

Common questions

Does MultiMail handle CAN-SPAM compliance for transactional emails?
Yes. MultiMail enforces CAN-SPAM requirements at the infrastructure layer: physical mailing address in the footer, accurate from-address, working unsubscribe mechanism, and header compliance. Transactional emails — receipts, confirmations, account alerts — have narrower CAN-SPAM obligations than commercial marketing email, but MultiMail applies the required protections to both categories. Opt-out requests are processed and honored within the 10-business-day window required by law.
How does MultiMail protect sender reputation when addresses bounce?
Hard-bounced addresses are automatically suppressed from future sends at the infrastructure layer — your agent does not need to maintain a suppression list. You also receive an email.bounced webhook event with the bounce type (hard or soft), recipient address, and any metadata you passed at send time. Wire your webhook handler to flag invalid addresses in your CRM or customer database so your agent does not attempt future sends to those addresses.
What oversight mode should I use for high-volume order confirmations?
Monitored mode is the standard choice for transactional email at volume. It allows agents to send without approval gates — necessary for sub-second delivery of order confirmations — while logging every message for operator review. Use gated_send for lower-volume or higher-stakes transactional emails (e.g., wire transfer confirmations in fintech) where added latency is acceptable in exchange for per-message human verification.
Can I attach metadata to sends so delivery events correlate with my business records?
Yes. Pass a metadata object when calling send_email — fields like order_id, user_id, and event are common choices. MultiMail includes this metadata in all webhook events associated with that message: delivered, bounced, and complained. This lets your webhook handler update order records or flag invalid addresses without a separate message-to-record mapping table.
Is DKIM signing automatic or do I need to configure it per-send?
DKIM signing is automatic for all outbound sends. When you provision a mailbox on a custom domain, MultiMail generates a DKIM keypair and provides the DNS TXT record to publish. After DNS propagation, every message from that domain is signed at the infrastructure layer. Agents do not manage DKIM keys or signing logic — it runs transparently on every send.
Can I use the MCP server to send transactional email from Claude Desktop or Cursor?
Yes. The send_email MCP tool accepts the same parameters as the REST API — from, to, subject, body, and metadata. This is useful for agents running interactively in MCP-compatible clients that need to send a transactional email as part of a longer workflow. For production high-volume transactional workloads, the REST API or Python SDK is the appropriate choice — MCP tools are optimized for interactive, lower-frequency agent workflows.

Explore more use cases

The only agent email with a verifiable sender

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