Jian/ Docs

Email

Give an agent an email address on your own domain through Resend or Cloudflare, and control who it can write to and how it answers.

An agent can have an address of its own, such as mia@agents.example.com. It reads what arrives there and answers when someone is waiting for a reply. It can also write to anyone, with your approval the first time.

Email is a channel, so it lives on a server gateway, under Agent settings → Channels.

Try asking

Email Kai at Harbor Studio to confirm Thursday's review, and copy Sam. Attach the agenda.

Search everything you've sent and received for the invoice from last month.

Sign up for the Harbor Studio newsletter with your own address and tell me when the confirmation arrives.

Connect an address

Open Agent settings → Channels → Add a channel

Choose Email, then a provider: Resend or Cloudflare.

Prepare the domain

  • Resend: the domain must be verified in Resend, with receiving on and its MX record in place. Use an API key with full access, so Jian can check the domain and register the webhook.
  • Cloudflare: the domain must be a zone in the account with Email Routing enabled, and onboarded in Email Sending. Use an API token with these permissions: Account › Email Sending: Edit, Account › Workers Scripts: Edit, Zone › Email Routing Rules: Edit, Zone › Zone Settings: Read and Zone › Zone: Read. Enter the Account ID too.

Keys and tokens are encrypted on the gateway and never shown again.

Enter the address and connect

Type the Address the agent sends from and reads. Jian does the rest. On Cloudflare it uploads a Worker that forwards the address's mail and adds its routing rule, and it removes both when you disconnect.

Incoming mail reaches the gateway at its public address, so set JIAN_PUBLIC_URL. See Gateway configuration.

What comes in

  • Mail is taken in only when its sender's domain authenticates it. Anything else is ignored.
  • Auto-replies and mailing lists are ignored.
  • A stranger waits as a pending contact until you approve them.
  • Each correspondent gets a conversation of their own. Replies stay in their thread, and attachments travel both ways.
  • A forwarded email reaches the agent whole, up to the 7,800 characters a turn takes.
  • Mail from noreply, no-reply, donotreply, mailer-daemon, postmaster and bounce addresses is kept without starting a turn, and the agent never writes to them.

How the agent answers

A turn in an email conversation doesn't mail its final answer back. The agent replies in the thread only when the sender is waiting for an answer, and tells you in your own conversation what matters. When a service asks for something only you have, such as a code, a password or a payment, it asks you first.

Writing to someone

The agent can email any address, using send_email.

  • The first email to someone who isn't an approved contact waits for your approval, and so does one that copies such an address. You see each address, the files with their sizes, and the subject. After that, each of those addresses is a contact, and later emails go out without asking.
  • Email goes out formatted, with a plain-text copy for mail clients that show only text.
  • It can copy up to 10 addresses and attach up to 5 files, 16 MB each and 20 MB together.
  • A reply in a correspondent's conversation goes to that person alone.
  • Before signing up to a service with its own address, it calls expect_email: for 30 days, signed mail from that domain is taken in even though the sender isn't a contact. It then finds the confirmation code or link with search_email, which also searches everything it has sent and received. Mailbox providers such as gmail.com are refused.

On this page