> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openmail.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Use OpenMail in a mail app (IMAP / SMTP)

> Read and send an inbox's mail from Apple Mail, Outlook, Thunderbird or a phone mail app. Sign in over IMAP and SMTP with the inbox address and an inbox-scoped API key.

Mail apps such as Apple Mail, Outlook, Thunderbird and the mail app on your phone can read and send an OpenMail inbox's mail. The app signs in with the inbox's full address as the username and an [inbox-scoped API key](https://docs.openmail.sh/concepts/inboxes.md#inbox-scoped-api-keys) as the password. That key needs IMAP / SMTP access switched on.

## Server settings

| Setting | Incoming (IMAP) | Outgoing (SMTP) |
| - | - | - |
| Server | `imap.openmail.sh` | `smtp.openmail.sh` |
| Port | `993` | `465` |
| Security | SSL/TLS | SSL/TLS |
| Username | The inbox's full address, for example `support@omail.sh` | The same address |
| Password | An inbox-scoped API key with IMAP / SMTP access | The same key |

Both servers use SSL/TLS from the first byte. Choose **SSL/TLS**, not **STARTTLS**. If the app asks how to authenticate, choose the normal password option.

## Set up in the console

**1. Open the inbox's settings**

Open the inbox from [Inboxes](https://console.openmail.sh/inboxes) and click **Inbox settings** at the bottom of its sidebar. The **IMAP / SMTP** section shows both servers, the username, and the inbox's keys.

**2. Create a key**

Click **Create key** and name it after the device, for example `Laptop`. Copy the key. It's shown once and can't be retrieved again.

A key created here starts with IMAP / SMTP access on. A key created anywhere else works only for the API until you switch it on in the key list.

**3. Add the account to your mail app**

In your mail app, add an account and choose to set it up manually, or pick **Other** or **IMAP**. Enter the [server settings](#server-settings), with the inbox's address as the username and the key as the password. Use the same username and password for both servers.

Any member of your organisation can create and revoke inbox keys and change their switches. The [API keys](https://console.openmail.sh/api-keys) page marks each key that mail apps use with an **IMAP / SMTP** badge.

> [!TIP]
>
> Create one key per device. You can then sign one device out without touching the others.

## Set up with the API

Use an account-wide key, or a pod-scoped key for the inbox's pod. Inbox-scoped keys can't create, change, list or revoke keys.

```bash theme={"theme":{"light":"github-light","dark":"dark-plus"}}
# Get the username and both servers
curl https://api.openmail.sh/v1/inboxes/INBOX_ID/mail-client \
  -H "Authorization: Bearer $OPENMAIL_API_KEY"
# 200 -> { "inboxId": "...", "username": "support@omail.sh",
#          "imap": { "host": "imap.openmail.sh", "port": 993 },
#          "smtp": { "host": "smtp.openmail.sh", "port": 465 } }

# Mint a key with IMAP / SMTP access on
curl -X POST https://api.openmail.sh/v1/inboxes/INBOX_ID/api-keys \
  -H "Authorization: Bearer $OPENMAIL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Laptop", "mailAccess": true}'
# 201 -> { "id": "...", "token": "om_...", "inboxId": "...", "mailAccess": true, ... }

# Turn access on for a key you already have
curl -X PATCH https://api.openmail.sh/v1/inboxes/INBOX_ID/api-keys/KEY_ID \
  -H "Authorization: Bearer $OPENMAIL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"mailAccess": true}'
```

The `token` in the create response is the password. It's returned once, so store it straight away. Turning access on for an existing key only helps if you still have that key's value. Every key object includes `mailAccess`, so listing the inbox's keys with `GET /v1/inboxes/{id}/api-keys` shows which ones mail apps can use.

Any key that can reach the inbox can read the settings, including the inbox's own inbox-scoped key.

## Set up with the CLI or MCP

With the [CLI](https://docs.openmail.sh/integrations/cli.md), version 0.16.0 or later:

```bash theme={"theme":{"light":"github-light","dark":"dark-plus"}}
openmail inbox mail-client --inbox-id INBOX_ID                                   # username, servers and ports
openmail inbox keys create --inbox-id INBOX_ID --name "Laptop" --mail-access     # prints the key once
openmail inbox keys update --inbox-id INBOX_ID --key-id KEY_ID --mail-access true
```

Over [MCP](https://docs.openmail.sh/integrations/mcp.md), ask your agent for the inbox's mail app settings. It calls `get_mail_client_settings`, and `set_inbox_key_mail_access` turns access on or off for an existing key. When you signed in with OAuth, the agent never creates the key itself. It sends you to the inbox's settings in the console, so the key doesn't end up in the chat. Turning access on or off over OAuth needs the **Set up inboxes** scope.

## What a mail app can do

The mail app works on the same mailbox as the API and the console.

* It sees Inbox, Sent, Drafts, Archive, Junk, Trash and your custom folders.
* It can file messages into folders, create, rename and delete custom folders, mark messages read or flagged, and edit drafts.
* It gets new mail pushed as it arrives (IMAP IDLE), so you don't have to wait for the app to check.
* Mail it sends goes out through OpenMail like mail sent with the API. [Sender rules](https://docs.openmail.sh/concepts/sender-rules.md), [rate limits](https://docs.openmail.sh/concepts/rate-limits.md) and billing apply, and the message is saved in Sent.
* Deleting a message moves it to Trash in most mail apps. That is the same [Trash](https://docs.openmail.sh/concepts/threading.md#deleting-mail) the console shows, and it empties itself after 30 days. Emptying Trash in the app, or an app set to delete without Trash, deletes the message for good.

> [!WARNING]
>
> Read state is shared. Opening a message in a mail app marks it read for the API too, so an agent that polls for [unread threads](https://docs.openmail.sh/concepts/threading.md#read/unread-tracking) skips it. If a person and an agent share an inbox, have the agent react to [webhooks](https://docs.openmail.sh/concepts/webhooks.md) or [WebSocket](https://docs.openmail.sh/concepts/websockets.md) events, not to unread state.

## Limits

| Limit | Value |
| - | - |
| Recipients per message (To, Cc and Bcc together) | 50 |
| Message size | 25 MB for the whole message as sent. Attachments grow by about a third when encoded, so that is about 18 MB of files. |
| Reply-To addresses | 1 |
| Sender | The inbox's own address |
| Active keys per inbox | 20 |

## Turn access off or revoke a key

To sign a mail app out, switch the key off under **IMAP / SMTP** in the inbox's settings, run `openmail inbox keys update --mail-access false`, or send `{"mailAccess": false}`:

```bash theme={"theme":{"light":"github-light","dark":"dark-plus"}}
curl -X PATCH https://api.openmail.sh/v1/inboxes/INBOX_ID/api-keys/KEY_ID \
  -H "Authorization: Bearer $OPENMAIL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"mailAccess": false}'
```

The mail app is signed out within a few seconds. The key keeps working for the API.

A key with access on can't be revoked. Switch it off first, then revoke it on the [API keys](https://console.openmail.sh/api-keys) page or with `DELETE /v1/inboxes/{id}/api-keys/{keyId}`. Revoking a key that still has access on returns `409 api_key_in_use`.

To replace a key, create a new one, update the password in the mail app, then switch the old key off and revoke it.

> [!WARNING]
>
> The key in a mail app is a full inbox-scoped API key, so treat it like a password. It can read and send from the inbox through the API. Through the mail app it can also delete mail and manage folders, which an inbox-scoped key can't do through the API. Give each mail app a key of its own, and don't switch access on for a key an agent uses.
>
> Keys belong to the organisation, not to a member: removing a member doesn't revoke keys they know. Switch off and revoke those keys yourself.

## Troubleshooting

> [accordion] The mail app can't sign in
>
> Check that:
>
> * The username is the inbox's full address, such as `support@omail.sh`, not your console email or the key name.
> * The password is a key for this inbox, starts with `om_`, and was pasted in full.
> * The key's switch is on under **IMAP / SMTP** in the inbox's settings. A key created on the API keys page starts with it off, and so does one minted with the API or CLI unless you asked for mail access.
> * Security is **SSL/TLS** on ports `993` and `465`, not STARTTLS.
>
> A key that was switched off or revoked signs the app out. Create a new key, or switch the old one back on, and update the password in the app.

> [accordion] Every sent message appears twice in Sent
>
> OpenMail saves mail sent over SMTP in Sent itself. If your app also saves its own copy and you see both, turn off the app's option to keep a copy of sent messages on the server.

> [accordion] A message won't send
>
> Check the [limits](#limits): at most 50 recipients, 25 MB and one Reply-To address, sent from the inbox's own address. Sender rules and rate limits apply to mail apps too, so a send the API would refuse is refused here as well. An inbox on a [custom domain](https://docs.openmail.sh/concepts/custom-domains.md) also needs the domain to be verified and your organisation to be on a paid plan.

## Related

* [Inbox-scoped API keys](https://docs.openmail.sh/concepts/inboxes.md#inbox-scoped-api-keys): what the key can reach.
* [Authentication](https://docs.openmail.sh/api-reference/authentication.md#key-scopes): all three key scopes.
* [Agent keys](https://docs.openmail.sh/best-practices/api-key-scopes.md): rotating and revoking keys.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.