Documentation navigation

Guide · Updated October 2026

Email for Claude Code, Codex, OpenClaw, Hermes and Pi

Every MarkRelay deployment serves an Agent Skill at /skills/SKILL.md in the open Agent Skills format. Install it in Claude Code, Codex, OpenClaw, Hermes Agent or Pi, give the agent the API URL and a key scoped to its mailbox, and it can check, read, send, reply to and forward email from your own domain. The same file works in every one of them.

Before you start

  1. Create a mailbox for the agent, such as agent@yourdomain.com, or pick the mailboxes it should work in.
  2. In Developer → API keys, create a key with Specific mailboxes scope. The agent can never reach more than you can, and with this scope it reaches only what you pick.
  3. Copy the key; it starts with sk-.
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 for the agent, scoped to agent@acme.com only.

Install the skill

Pick your agent. The fastest way is to paste one message and let the agent install the skill itself: it downloads the file, asks you for the key, stores it where it belongs and checks the connection. The manual steps are underneath. Claude Code reads skills from ~/.claude/skills; Codex, OpenClaw and Pi all read ~/.agents/skills; Hermes installs straight from your deployment's URL.

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 it looks like

Ask in plain language. The skill tells the agent which calls to make, how to page through results, and what never to retry.

claude — ~/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.
An example session against a demo deployment. The API calls and answers are real; the conversation is illustrative.

Things to ask

  • “Check support@acme.com for mail since 9am and summarize what needs a reply.”
  • “Reply to the latest message from Priya Nair: the export fix ships today.”
  • “Send ./reports/october.pdf to billing@brightpath.io from billing@acme.com.”
  • “Forward every unread invoice email in billing@ to accounts@acme.com, then archive them.”
  • “Draft replies to new sales@ inquiries and leave them for me to review.”

Keep it safe

  • Give each agent its own key with the narrowest scope that works, and keep it out of repositories.
  • When the agent installs the skill for you, the key you paste stays in that conversation's history. If you would rather it did not, use the manual steps.
  • Ask the agent to draft and wait for your approval before it sends anything sensitive.

The full list, including what the skill tells agents never to retry, is in the agent skill reference.

Why a mailbox of its own instead of your Gmail: see give an agent one mailbox, not your whole inbox.

mail.yourdomain.com
A reply sent by an AI agent through the API, shown in webmail with an API badge
Everything an agent sends shows up in webmail with an API badge, so your team can check it.

Other agents

Claude, ChatGPT, Cursor and other MCP clients connect to your deployment's MCP server with a sign-in instead of a skill. Agents without either can use the same HTTP API through your deployment's /llms.txt or OpenAPI document; see what each deployment serves.

One page per agent

Common questions

Which AI agents work with MarkRelay?

Claude Code, Codex, OpenClaw, Hermes Agent and Pi load the skill your deployment serves at /skills/SKILL.md, which follows the open Agent Skills format. Any other agent that can make HTTP requests can use the same API through the deployment's llms.txt or OpenAPI document.

Can I ask OpenClaw or Hermes about my email from my phone?

Yes. Both run as personal assistants you can message from chat apps such as Telegram or WhatsApp. Once the skill and key are set up, ask them to check a mailbox, summarize new mail or send a reply.

Is there an MCP server?

Yes. Every deployment is a remote MCP server at /mcp; Claude, ChatGPT, Cursor and other MCP clients connect with OAuth, see the MCP server guide. The skill is the other way in: the agent calls the plain HTTP API with curl or its own HTTP tool, so there is no server to run next to the agent.

Can the agent read every mailbox?

Only the mailboxes its key reaches. Create a key with Specific mailboxes scope, for example agent@ only, and the agent cannot list or read anything else.

Does the skill stay up to date?

Your deployment builds the skill for its own API URL and version. After you update MarkRelay, download SKILL.md again to pick up any changes.

Related: Agent skill reference, Email API and email for AI agents.

Compare