All solutions

Solutions

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

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 refuses cold outreach inside the send call — 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: "support",
  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("support").onReply((event) => {
  if ((event.injection_score ?? 0) > 0.5) return;   // never act on an attack
  if (event.intent === "ask_question") {
    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 high scores are quarantined before delivery. 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.

What it costs to run one

Free covers 3,000 sends and 3,000 inbound a month with one agent and no card. Beyond that, sends are $0.001, inbound is $0.002 including parsing and the injection scan, and intent/entity classification is $0.003 more when you want routing decided before the model runs.

Frequently asked questions

Why can't I just use a normal email API for my agent?

You can send with one. The two things you can't do are receive and be constrained. A send-only API leaves you writing IMAP polling and MIME parsing to read replies, and gives your agent no boundary — if a prompt talks it 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 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 — if injection_score > 0.5, don't act — 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.

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