MaillyDocs

Give Codex its own email address

Connect OpenAI Codex (CLI, IDE extension and the ChatGPT desktop app) to a Mailly inbox over Remote MCP with OAuth.

Codex can work from a real inbox: search threads, read incoming mail, save reply drafts and send once you approve the final text. Mailly gives it an address such as your-name@mailly.site and connects over Remote MCP. The Codex CLI, the IDE extension and the ChatGPT desktop app share one MCP configuration, so you set Mailly up once.

What you get

  • A two-way inbox on @mailly.site, or on your own domain on the Developer plan.
  • About 70 typed MCP tools for threads, drafts, sending, domains, contacts, templates, campaigns and workflows, limited to the permissions you grant.
  • Sending under your control: Codex shows the exact text and recipients, and sends only after you confirm.

Get an inbox

Already have a Mailly account? Skip to the next step.

Paste this prompt into Codex. It reads Mailly's setup instructions, asks for the name you want, reserves it over HTTP and gives you a verification link.

Prompt
Read https://mailly.site/auth.md
and set up a Mailly inbox for me over HTTP.
Ask me for the name if unknown; if taken, ask for another,
with no blind retries.
Send me the verification link.
After I confirm the inbox in my browser,
store the API key securely, tell me the address,
and ask me before sending any email.

Open the link, sign in or register with your own verified email, and confirm the inbox. Codex then receives the address and your account's API key. If Codex can't reach the network from its sandbox, start at mailly.site/onboard instead. See Let an agent set up an inbox for the rules.

Add the Mailly MCP server

codex mcp add mailly --url https://mcp.mailly.site/mcp

This writes the server to ~/.codex/config.toml. You can also add it by hand:

~/.codex/config.toml
[mcp_servers.mailly]
url = "https://mcp.mailly.site/mcp"

A project-level .codex/config.toml works too, but only in trusted projects.

Sign in and choose permissions

codex mcp login mailly

Your browser opens Mailly's sign-in and consent page. Mailly accepts Codex's published client identity, so there is no client ID or secret to enter. Choose what Codex may do:

PermissionWhat Codex can do
mail:readRead your inboxes, threads, sent mail, drafts and settings. Always granted.
mail:draftSave, edit and discard reply drafts. No sending.
mail:sendSend replies, forwards and new emails you have reviewed.
workspace:manageManage addresses, domains, templates, contacts, campaigns, workflows and webhooks.

Headless runs

For CI or a machine without a browser, Codex can send your Mailly API key as a bearer token read from an environment variable:

~/.codex/config.toml
[mcp_servers.mailly]
url = "https://mcp.mailly.site/mcp"
bearer_token_env_var = "MAILLY_API_KEY"

An API key carries full account access; permission scopes don't apply to it. Keep it in an environment variable, never in chat or committed files. Find it under Integration in the workspace.

Verify the connection

  1. Run codex mcp list and check that mailly is listed. In the Codex TUI, /mcp shows the active servers.
  2. Ask Codex: "Use Mailly to list my inbox addresses and my five most recent threads." It should call mailly_list_inbox_addresses and mailly_list_threads.
  3. Send an email from your personal account to your Mailly address, then ask: "Read my latest Mailly thread and save a reply draft. Show me the exact text and don't send it." Codex calls mailly_read_thread and mailly_save_draft. Approve or discard the draft in the conversation.

Use the CLI instead

Codex can also drive mailly-cli through its shell, if its sandbox allows network access. Every command accepts --json.

npm install -g mailly-cli   # Node.js 18+
mailly login                # browser sign-in; --no-browser on remote machines
mailly inbox addresses list --json
mailly inbox threads list --json

Troubleshooting

  • Mailly tools fail with an authorization error: run codex mcp login mailly again.
  • A tool you expected is missing: it needs a permission you didn't grant. Run codex mcp login mailly again and grant the permission on Mailly's consent page. Mailly never widens an existing grant on its own.
  • A project's .codex/config.toml is ignored: Codex reads project MCP settings only in trusted projects. Add Mailly to ~/.codex/config.toml instead.
  • No mail arrives: check the address in the workspace and look in the inbox's Spam folder.
  • A send is refused: check your balance and limits with mailly_account. The Free plan allows 100 send recipients per rolling 24 hours; see pricing.

On this page