All solutions
Solutions

AI Email Agent: Give One a Real Inbox It Can Send and Receive From

The infrastructure an AI email agent actually needs — its own inbox, replies as events, and a firewall on both directions.

An AI email agent is a program that sends and answers email on its own, which means it needs an identity and an inbox rather than just an SMTP credential. Mails.ai gives each agent its own address, turns every reply into a structured event with an injection score, and checks every send before it leaves, inside the domains and caps you set for that agent — so an agent can run email without being able to burn the domain it sends from.

An agent that only sends is half an agent

The moment an AI email agent does anything real — confirms a booking, chases an invoice, answers a support thread — it has to read the reply. That is where a plain send API runs out: you end up writing an IMAP loop, an OAuth refresh, a MIME parser and your own threading, none of which belongs in an agent runtime.

Give the agent an identity instead. It gets a sending address and a receiving address, and inbound arrives as an event shaped like every other event your code already consumes:

import { createClient } from "@mailsai/sdk";
const mails = createClient();

// Sending: no agent to pre-create, no domain to verify, no DNS.
await mails.send({
  from: "hello",
  to: "customer@example.com",
  subject: "Your invoice #221 is ready",
  body: "Invoice #221 for March is attached, due the 30th.",
});

// Receiving: replies arrive as typed events, already threaded and scanned.
mails.agent("hello").onReply((event) => {
  // Hold for a person: quarantined, not scanned (no score), or 0.5 and up
  if (event.quarantined || typeof event.injection_score !== "number" || event.injection_score >= 0.5) {
    return flagForReview(event);
  }
  if (event.source_message_id) {
    mails.messages.reply(event.source_message_id, { body: answer(event) });
  }
});

Two boundaries, both enforced by the API

An agent with email is exposed in both directions, and a prompt is not a control. Inbound, anything it reads is untrusted input that may be trying to redirect it — so every message carries an injection_score and its flagged categories, and scores of 0.95 or above arrive flagged quarantined. Outbound, an agent that is talked into prospecting would spend a sending reputation it did not build — so cold and bulk mail is refused in the send call, with a reason the agent can read and a second review if the verdict looks wrong.

Reputation is scored per agent, not per account. One misbehaving agent auto-suspends at a 0.3% complaint rate, before the upstream provider’s 0.5% threshold ever sees it, and your other agents keep sending unless the workspace’s mail as a whole crosses the line too.

What it costs to run one

Free covers 3,000 emails and 3,000 inbound replies a month with one agent and no card. Beyond that, Pro is $20 a month for 50,000 emails and 50,000 inbound replies across five agents, and Scale is $99 for 250,000 emails and 500,000 inbound replies with unlimited agents. Parsing and the injection scan come with every inbound, and intent/entity classification of first-contact mail is opt-in on paid plans at no extra charge when you want routing decided before the model runs. For the operational layer above individual agents — routing, classification, reputation monitoring — see AI email management.

Frequently asked questions

Why can’t I just use a normal email API for my agent?
You can send with one, and most can receive too. The two things you don’t get are replies your agent can act on and a boundary: inbound arrives as a message your code still has to thread and screen for injection, and if a prompt talks your agent into emailing 500 strangers, it will. Both of those are the agent-specific half.
What stops the agent from being manipulated by an email it reads?
Every inbound message within your plan’s limits is scanned for prompt injection across six categories before your agent sees it, and the score arrives on the event. Your code branches on a number — at 0.5 or more, or with no score, hold the message for a person — rather than asking your model to notice it’s being attacked inside the same prompt as the attack.
Can the agent reply in the same thread?
Yes. Replies reuse the Message-ID chain, so they land inside the existing conversation in the recipient’s mail client instead of starting a new one. Threading is handled for you; you pass the message id you’re replying to.
What if my agent tries to send cold outreach?
It gets 422 cold_email_prohibited and nothing is transmitted. That is deliberate and it is not configurable, because a shared sending estate only stays deliverable if nobody on it can send cold mail. Transactional mail — confirmations, receipts, codes, notifications, genuine replies — passes.
How do I test it without emailing anyone?
Use a test key (mk_test_…). It runs the entire real request path — validation, the firewall, threading, events, webhooks — and transmits nothing. Test keys also unlock an inbound simulator, so you can build and verify the receive half before any mail moves.

Explore the product

Give your first agent an inbox

Free covers 3,000 emails and 3,000 inbound replies a month, with no card. Upgrade when your agents get busy.

Get your API key