All solutions

Solutions

Email for AI Agents: Send, Receive, and Reply Without an SMTP Rabbit Hole

Email for AI agents is a bidirectional stack: each agent gets a dedicated address to send from and receive to, every inbound message arrives as a structured event with an injection score instead of raw MIME, and cold outreach is blocked at the API so the sending reputation your agents build stays intact. Mails.ai is built for exactly this — per-agent identity, event-driven receiving, and a firewall in both directions.

Send and receive under one API key

The minimal email setup for an AI agent is a send API. It works — until the customer replies. At that point you need inbound parsing, threading, and a way to route the reply back to the agent that sent the original message. That is the gap a plain SMTP relay cannot fill:

import Mails from "@mailsai/sdk";
const mails = new Mails({ apiKey: process.env.MAILS_API_KEY });

// Sending: one call, no DNS to configure, no domain to verify upfront.
await mails.messages.send({
  agent: "billing",          // creates the agent if it doesn't exist yet
  to: "customer@example.com",
  subject: "Your invoice #441 is ready",
  body_text: "Invoice #441 for August is attached — reply with any questions.",
});
// → billing@yourworkspace.mails.ai, SPF/DKIM/DMARC aligned

// Receiving: replies arrive as typed events, already parsed and injection-scanned.
mails.events.on("message.received", async (event) => {
  // event.body_text  — clean plain-text body, no MIME handling needed
  // event.thread_id  — stable across the whole conversation
  // event.injection_score — 0.0–1.0; quarantine above 0.5
  if ((event.injection_score ?? 0) > 0.5) return;

  // Reply in the same thread — no Message-ID wrangling.
  await mails.messages.reply(event.message_id, {
    body_text: "Got it — I'll process that and follow up by end of day.",
  });
});

Reputation stays per agent, not per account

A shared sending domain fails when one sender misbehaves and the whole domain takes the bounce or complaint hit. Here, each AI email agent has its own reputation score. An agent whose complaint rate drifts above 0.3 % — below the upstream threshold of 0.5 % — is suspended automatically before the damage propagates. Your other agents keep sending.

For higher-volume workloads or when a single agent’s reputation needs to be fully isolated from the shared pool, automated dedicated IP warm-up moves that agent onto its own IP without a manual warmup schedule.

Custom domain, same model

By default agents send from their built-in address on the workspace subdomain — working email in one API call, no DNS required. When your agents need to carry your brand, connect a custom domain and every agent on it sends as agent@yourcompany.com, authenticated end to end. Custom domain email for AI agents covers the DNS steps — they’re generated for you and verified automatically.

What it costs

The free tier covers 3,000 sends and 3,000 inbound messages a month with one agent — no card required. Beyond that: $0.001 per outbound message, $0.002 per inbound including parsing and the injection scan, and $0.003 more for intent/entity classification if you want routing decided before your model runs. No monthly minimum, no per-seat fee.

Frequently asked questions

Can't I just use a standard email API like SendGrid or Postmark?

For fire-and-forget sends, yes. The gap appears the moment your agent needs to read a reply: classic APIs have no inbound layer, so you end up writing IMAP polling, OAuth refresh, and MIME parsing yourself. Mails.ai wraps both directions — send and receive — under one API key, with replies delivered as JSON events rather than raw email.

What does 'per-agent identity' mean in practice?

Each agent you create gets its own email address (agent@yourworkspace.mails.ai, or agent@yourdomain.com when you bring a custom domain). SPF, DKIM, and DMARC are provisioned for you. Reputation signals — bounce rate, complaint rate, engagement — are tracked per agent, so one misbehaving agent can't drag down the reputation of others in the same account.

How does the injection-scan protect my agent?

Every inbound message is scanned for prompt-injection patterns before it reaches your code. The score arrives on the event alongside the parsed body, so your agent branches on a number — if injection_score > 0.5, quarantine — rather than relying on the LLM to notice it's being attacked inside the same prompt as the attack.

What email can my agents actually send?

Transactional mail: confirmations, receipts, OTPs, status updates, notifications, and genuine replies to messages the agent received. Cold outreach is refused at the API and never transmitted — by policy and by enforcement. That boundary keeps the shared sending infrastructure clean, which is why transactional mail from agents here inboxes reliably.

Live now

Built for agents.
Self-serve in minutes.

The API is live and self-serve. Drop ~6 lines into your agent and ship.

npmpnpmbunnpx
$ npm install @mailsai/sdk
Live on npm today · @mailsai/sdk + @mailsai/mcp-server