# Send & Receive Emails with OpenAI Codex (/integrations/frameworks/codex)

<!-- agent-signals: reading_time_min: 4 · est_tokens: 1285 · updated: 2026-09-06 -->
Related: [Send & Receive Emails with Claude Cowork](/integrations/frameworks/claude-cowork.md), [Send & Receive Emails with Claude Code](/integrations/frameworks/claude-code.md), [Send & Receive Emails with OpenClaw](/integrations/frameworks/openclaw.md), [Send & Receive Emails with Grok](/integrations/frameworks/grok.md), [Send & Receive Emails with Manus](/integrations/frameworks/manus.md), [Send & Receive Emails with Cursor](/integrations/frameworks/cursor.md)



# Connect OpenAI Codex to AgentMail

Installing the AgentMail plugin gives Codex the hosted MCP server and the AgentMail skills in one install, so it can create `@agentmail.to` inboxes, send email, and check replies from a session. Use this path for the Codex CLI or the ChatGPT desktop app, and the API-key options below for shared machines, CI, and Codex cloud tasks.

## Do this

Requires an AgentMail account (create one at `https://console.agentmail.to`). The plugin authenticates with OAuth, no API key needed.

```bash
npm install -g @openai/codex
codex login

codex plugin marketplace add agentmail-to/agentmail-plugins
codex plugin add agentmail@agentmail

# optional: sign in to AgentMail ahead of time instead of letting
# the first tool call open the browser sign-in
codex mcp login agentmail
```

Start a new Codex session after installing, complete the browser sign-in on the AgentMail page if prompted, then test with the prompt `List my AgentMail inboxes.`

## Facts

* The plugin bundles the AgentMail skills and the hosted MCP server at `https://mcp.agentmail.to/mcp`. One install adds both.
* ChatGPT desktop app: install from the Plugins tab. Search for AgentMail, select the plus button, start a new chat.
* `codex plugin list` shows the install as `agentmail@agentmail  installed, enabled`.
* `codex mcp list` shows the connection. The `Auth` column reads `Not logged in` until the browser sign-in finishes.
* `/mcp` inside a session lists the AgentMail tools Codex can call.
* Accounts in more than one organization: ask Codex to list organizations and select the one to work in. Signed-in sessions include tools for both.
* Skills: `$send-email` drafts and delivers mail, `$check-email` reads and triages it, `$manage-inboxes` handles the inbox lifecycle. Codex picks one on its own, or type `$` in the composer to invoke one by name.
* Skills treat email content as untrusted data. Compose requests create drafts rather than sending. Sends require explicit or previously confirmed details. Inbox deletion requires confirming the exact address.
* Inbox usernames are first come, first served. Skipping the username always works because AgentMail generates the address.
* API key alternative when a browser sign-in is not possible: configure the local bridge in `~/.codex/config.toml` and export `AGENTMAIL_API_KEY` in the shell that starts Codex (`env_vars` passes it through). Keys come from `https://console.agentmail.to/dashboard/api-keys`.

```toml
[mcp_servers.agentmail]
command = "npx"
args = ["-y", "agentmail-mcp"]
env_vars = ["AGENTMAIL_API_KEY"]
```

* Codex cloud tasks run in isolated containers configured per repository at `https://chatgpt.com/codex/settings/environments`. Give them email access with an API key and the AgentMail CLI:
  1. Add `AGENTMAIL_API_KEY` as an environment variable. Environment variables stay set for the whole task.
  2. Install the CLI in the environment's setup script (setup scripts run with internet access): `npm install -g agentmail-cli`
  3. Turn on agent internet access for the environment and add `api.agentmail.to` to the allowed domains.

## Not supported

* `codex exec` denies tool approvals by default, and sending a message asks for one. Pass `--approve-for-me` for non-interactive runs.
* Cloud task agents have no internet access by default. Without `api.agentmail.to` on the environment's allowed domains, the task cannot reach AgentMail.
* Cloud task secrets are decrypted only for setup scripts and removed before the agent starts. Store `AGENTMAIL_API_KEY` as an environment variable, not a secret, when the agent needs it while it works.
* Asking Codex to compose an email creates a draft, it does not send.

## Errors

| Error                 | HTTP status             | Cause                                                        | Fix                                                                                                                                  |
| --------------------- | ----------------------- | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------ |
| `403` on inbox create | 403                     | Requested inbox username is taken (first come, first served) | The error reaches Codex as a tool result naming up to three available variants in `suggestions`. Retry with one or skip the username |
| `limit_exceeded`      | not stated on this page | Inbox count is at the plan's cap                             | Returned instead of the username error. Stay under the plan's inbox cap                                                              |

## Verify

```bash
codex plugin list
```

A row reading `agentmail@agentmail  installed, enabled` confirms the install. In a new session, the prompt `List my AgentMail inboxes.` returning your inboxes proves the whole path works.

## Related

* `/integrations/mcp-and-skills` - full hosted tool catalog and configuration for every other client
* `/core/send` - the send, list, and reply commands a cloud task runs with the CLI
