Send & receive from your agent
Once your agent is connected, the whole email loop is a handful of tool calls — no SMTP, no MIME, no polling. Here's the day-to-day.
Send
The agent calls mailkite_send over any verified domain:
// Send over any verified domain — HTML, text, cc/bcc, attachments
mailkite_send({
from: "agent@yourdomain.com",
to: "ada@example.com",
subject: "Your invoice #1042",
html: "<p>Thanks! Your receipt is attached.</p>"
})
// → { id: "msg_2Hk9…", status: "queued" } Receive
Every message that arrives is parsed and stored. The agent reads it with its
own tools — or you have MailKite POST each one to a
webhook the moment it lands:
// Read inbound the agent has stored, newest first
mailkite_list_messages({ limit: 20 })
// Pull one in full — decoded body, headers, deliveries, attachment links
mailkite_get_message({ id: "msg_2Hk9…" })
// → { from: { address }, subject, text, html, attachments: [ { filename, url } ], … } Reply in-thread
Pass the original message id as inReplyTo and your reply threads
correctly in the recipient's client:
// Reply in the same thread — pass the message id as inReplyTo
mailkite_send({
from: "agent@yourdomain.com",
to: "ada@example.com",
subject: "Re: Your invoice #1042",
inReplyTo: "msg_2Hk9…",
html: "<p>All sorted — your card is updated.</p>"
}) Attachments
Upload a file first and reference its URL instead of base64-inlining large payloads — inbound attachments arrive the same way, as signed links:
// Attach a file without base64-inlining it: upload, then reference the URL
const up = mailkite_upload_attachment({ filename: "receipt.pdf", /* file */ })
mailkite_send({
from: "agent@yourdomain.com",
to: "ada@example.com",
subject: "Your receipt",
html: "<p>Attached.</p>",
attachments: [{ filename: "receipt.pdf", url: up.url }]
}) A little about MailKite
MailKite is programmable email for developers and AI agents. Send, inbound-as- JSON, threaded replies, and attachments are all native tools over MCP — and the same calls exist in the SDKs, the CLI, and raw HTTP. To let the agent answer mail on its own, see Build a support inbox agent.
Next: Send API and Inbound webhooks for the full field reference.