AI agents

Email for Claude Code: a mailbox on your own domain

Create agent@yourdomain.com in your own Cloudflare account, give Claude Code a key that reaches only that mailbox, and install the MarkRelay skill. Claude Code can then read, search, send and reply from that address, and nothing else.

Facts checked

In short

Deploy MarkRelay to your Cloudflare account, create agent@yourdomain.com, create an API key scoped to that one mailbox, and install the MarkRelay skill in Claude Code. Claude Code loads it from ~/.claude/skills/markrelay-mail (or .claude/skills in one repository), picks it up when you ask about email, and runs it with /markrelay-mail. Claude Code can then check, read, search, send, reply to and forward mail from that address, and nothing else. Mail stays in your own Cloudflare D1 and R2, and MarkRelay charges nothing per inbox or per message.

What Claude Code can do with its mailbox

List the mailboxes its key can use

MarkRelay
GET /mailboxes

Check and search mail

MarkRelay
By folder, read state, sender, subject, text and date

Read a message and its attachments

MarkRelay
Yes

Send from its own address

MarkRelay
Up to 50 recipients, 5 MiB per message

Reply and forward in the same thread

MarkRelay
Yes

Mark read, star, move to a folder

MarkRelay
Yes

Reach other mailboxes

MarkRelay
No: the key reaches only the mailboxes you grant

Hear about new mail at once

MarkRelay
Signed webhook to your own runner

How it connects

MarkRelay
Agent Skill + HTTP API, or the remote MCP server

Needs

MarkRelay
A domain on Cloudflare DNS; Workers Paid to send

Its own address

agent@yourdomain.com, on your domain and in your Cloudflare account.

One mailbox, one key

The key reaches that mailbox and nothing else.

Installs as a skill

Claude Code loads the skill your deployment serves at /skills/SKILL.md.

People stay in the loop

Review and take over the agent's threads in webmail.

Set it up in Claude Code

1. Deploy MarkRelay with the Deploy to Cloudflare button and add your domain. 2. Create a mailbox for the agent, such as agent@yourdomain.com. 3. In Developer → API keys, create a key with Specific mailboxes scope and pick only that mailbox. 4. Install the skill your deployment serves at /skills/SKILL.md and give the agent the API URL and key.

The quickest way is to paste one message into Claude Code: it downloads the skill, asks you for the key, stores it and checks the connection.

The address you open MarkRelay at. The prompts and commands below fill it in; until then the prompt asks your agent to ask you.

Install the MarkRelay skill in Claude Code

Fastest: paste this into Claude Code

It installs the skill, asks you for the key, stores it, and checks the connection.

prompt
Set up the MarkRelay email skill for yourself. First ask me for my MarkRelay address (for example https://mail.example.com); below it is called MARKRELAY_URL. Then, download MARKRELAY_URL/skills/SKILL.md to ~/.claude/skills/markrelay-mail/SKILL.md. Then save MARKRELAY_API_URL=MARKRELAY_URL/openapi/v1 and MARKRELAY_API_KEY in the env section of ~/.claude/settings.json. Ask me for the key; never put it in a repository. Finally, use the skill to list the mailboxes the key can reach. Tell me if I need to restart Claude Code.

Or do it yourself

1. Install the skill

terminal
mkdir -p ~/.claude/skills/markrelay-mail
curl -fsS https://<your-deployment>/skills/SKILL.md \
  -o ~/.claude/skills/markrelay-mail/SKILL.md

2. Give it the API URL and key

~/.claude/settings.json
{
  "env": {
    "MARKRELAY_API_URL": "https://<your-deployment>/openapi/v1",
    "MARKRELAY_API_KEY": "sk-..."
  }
}

Or export the two variables in your shell before starting claude.

3. Ask, or call /markrelay-mail

  • Claude loads the skill on its own when you ask about email, or you can call it with /markrelay-mail.
  • For one repository only, put the skill in .claude/skills/markrelay-mail instead.

What to ask Claude Code

Talk to the agent in plain language. The skill tells it which calls to make, how to page through results, and never to retry a send without checking first.

  • “Check agent@ for new mail and summarize it.”
  • “Email the release notes in CHANGELOG.md to beta@acme.com.”
  • “Find the bug report Leo forwarded yesterday and open an issue for it.”
  • “Draft a reply to the latest support email, but show me before sending.”
claude code — ~/acme
›Check agent@acme.com for unread mail. Answer password-reset requests yourself and flag anything else for me.
●Using skill markrelay-mail
$curl -s -H "Authorization: Bearer $MARKRELAY_API_KEY" "$MARKRELAY_API_URL/emails?mailbox=agent@acme.com&read=false"
2 unread: “Reset my password please” (Sam Patel) · “Where is order #4830?” (Elena García)
$curl -s -X POST … "$MARKRELAY_API_URL/emails/b68419a2-…/reply" -d '{"text":"Hi Sam, I have sent a fresh reset link…"}'
{"id":"528a8469-74ee-4dc4-8023-0d3882699ad2"}
●Replied to Sam Patel with a fresh reset link. Elena García is asking about order #4830, which needs a tracking lookup, so I left it unread for you.
The API calls and answers are from a demo deployment; the conversation is illustrative.

Why not your personal Gmail

A key scoped to agent@yourdomain.com cannot open any other mailbox, so Claude Code never sees your personal or customer mail. The agent sends from your own domain, and its mail stays in your own Cloudflare account.

Everything the agent sends appears in MarkRelay's webmail with an API badge, so a person can review a thread, take over or reply by hand.

mail.yourdomain.com
The API keys page with the Create API key dialog open, its scope set to the agent@acme.com mailbox only
A key that reaches agent@acme.com and nothing else.

How it connects to Claude Code

The skill is a single SKILL.md file in the open Agent Skills format. Claude Code reads it when a task involves email and calls MarkRelay's HTTP API with curl, using MARKRELAY_API_URL and MARKRELAY_API_KEY from the env section of ~/.claude/settings.json.

Prefer MCP? Add your deployment's /mcp URL with claude mcp add --transport http and sign in; nothing extra to run either way. Every deployment also serves an OpenAPI 3.1 document and an llms.txt, so Claude Code can write integration code against your own API too.

MarkRelay, AgentMail or your own Gmail

Three ways to give an agent email, compared on what matters for an agent.

The agent's address

MarkRelay
agent@yourdomain.com
AgentMail
On AgentMail's domain, or yours on paid plans
Your Gmail
Your personal address

Where mail is stored

MarkRelay
Your Cloudflare D1 and R2
AgentMail
AgentMail's cloud
Your Gmail
Google

What the agent's key reaches

MarkRelay
Only the mailboxes you grant
AgentMail
The inboxes in your AgentMail account
Your Gmail
Whatever its OAuth scope allows in your mailbox

Price for more agents

MarkRelay
No per-inbox fee
AgentMail
3 inboxes free, then plans from $20/mo
Your Gmail
One Google account per address

People review in webmail

MarkRelay
Yes
AgentMail
—
Your Gmail
Yes

Installs as an Agent Skill

MarkRelay
Yes
AgentMail
—
Your Gmail
—

MCP server

MarkRelay
Yes
AgentMail
Yes
Your Gmail
—

AgentMail facts from agentmail.to/pricing. “—” means it does not say.

Common questions

How do I give Claude Code its own email address?

Create a mailbox such as agent@yourdomain.com in MarkRelay, create an API key scoped to that mailbox, and install the skill your deployment serves at /skills/SKILL.md in Claude Code with MARKRELAY_API_URL and MARKRELAY_API_KEY set. Claude Code loads it from ~/.claude/skills/markrelay-mail (or .claude/skills in one repository), picks it up when you ask about email, and runs it with /markrelay-mail.

Can Claude Code read my other mailboxes?

No. A key reaches only what its owner can open, narrowed to the scope chosen for it. A key scoped to agent@ sees no other mailbox, in any call.

Is there an MCP server?

Yes. Every deployment is a remote MCP server at /mcp: add the URL, sign in, and pick the mailboxes it may use. Agents that run commands can use the skill and plain HTTP API instead, so nothing extra runs next to the agent.

Can I install the skill for one project only?

Yes. Put it in .claude/skills/markrelay-mail inside the repository instead of ~/.claude/skills. Keep the API key out of the repository: set it in ~/.claude/settings.json or your shell.

Will Claude Code send email without asking?

The skill tells the agent to confirm before sending and never to retry a send blindly. Claude Code's own permission prompts also ask before it runs the curl command, unless you have allowed it.

What does it cost?

One MarkRelay license (Annual $99/year or Lifetime $249 once) covers any number of agent mailboxes. Cloudflare bills its own usage: Workers Paid ($5/month) includes 3,000 sent emails a month, then $0.35 per 1,000; receiving through Email Routing is free.

Go deeper

Explore more of MarkRelay

Use cases

Own your email stack today

Buy MarkRelay once and run it in your Cloudflare account. MarkRelay adds no per-message or per-seat charge; Cloudflare usage and service limits remain separate.