# Connect any IMAP server

> Connect any IMAP and SMTP mail account, what autodetection checks, ports and security options, certificates, folder mapping, IDLE and troubleshooting.

Source: https://docs.posternmail.app/providers/imap/

Postern works with any standard IMAP server for reading and SMTP server for sending: your web
host, your company's server, a Dovecot box at home, GMX, WEB.DE, Posteo, mailbox.org, Zoho and
many more. This page explains the settings, what the Hub detects for you and what to do when
the connection fails.

## Providers the Hub knows

For these the Hub fills in everything and shows a note about what the provider needs:

| Provider | Addresses | IMAP | SMTP | What you need |
|---|---|---|---|---|
| GMX (Germany, Austria, Switzerland) | `gmx.de`, `gmx.net`, `gmx.at`, `gmx.ch` | `imap.gmx.net:993` TLS | `mail.gmx.net:587` STARTTLS | Turn on POP3/IMAP access in the GMX web settings (**E-Mail → POP3/IMAP**). |
| GMX (international) | `gmx.com`, `gmx.us`, `gmx.co.uk`, `gmx.fr`, `gmx.es`, `gmx.it`, `gmx.ca`, `gmx.co.in` | `imap.gmx.com:993` TLS | `mail.gmx.com:587` STARTTLS | Turn on POP3/IMAP access in the GMX web settings. |
| WEB.DE | `web.de` | `imap.web.de:993` TLS | `smtp.web.de:587` STARTTLS | Turn on POP3/IMAP access in the WEB.DE web settings. |
| Posteo | `posteo.de` and Posteo's other domains | `posteo.de:993` TLS | `posteo.de:465` TLS | Your Posteo password. |
| mailbox.org | `mailbox.org`, custom domains on mailbox.org | `imap.mailbox.org:993` TLS | `smtp.mailbox.org:465` TLS | Your mailbox.org password. |
| Zoho Mail | `zoho.com`, `zohomail.com` and regional domains; custom domains on Zoho | `imap.zoho.com:993` TLS (regional: `.eu`, `.in`, `.com.au`, `.jp`, `.com.cn`; custom domains: `imappro.zoho.…`) | `smtp.zoho.com:465` TLS (custom domains: `smtppro.zoho.…`) | Enable IMAP in Zoho Mail (**Mail Accounts → IMAP**); with two-factor authentication, an app-specific password. |
| Proton Mail | `proton.me`, `protonmail.com`, `protonmail.ch`, `pm.me`, custom domains on Proton | `127.0.0.1:1143` STARTTLS | `127.0.0.1:1025` STARTTLS | Proton Mail Bridge (paid plans), running where the Hub can reach it. |

Gmail, Microsoft, iCloud, Yahoo, AOL and Fastmail have their own pages: see
[Connect mailboxes](https://docs.posternmail.app/providers/).

### Proton Mail through Bridge

Proton Mail does not offer IMAP directly; its Bridge app does. The Hub's note says: "Proton Mail
is only reachable through Proton Mail Bridge (paid plans). Run Bridge where the Hub can reach
it, use the password Bridge shows (not your Proton password) and, if Bridge runs on another
machine, replace 127.0.0.1 with its address. Bridge uses a self-signed certificate, so
certificate verification is turned off for it."

`127.0.0.1` is the Hub's own machine. In Docker that is the Hub container, not your server, so
put Bridge's address in **Server settings** instead. Bridge only listens on its own machine by
default; see Proton's Bridge documentation for making it reachable.

## Add the mailbox

### 1. Start the dialog

**Settings → Mailboxes → Add mailbox**, pick **Other**, type your full email address and click
**Continue**. The Hub looks up your settings (see
[What autodetection checks](https://docs.posternmail.app/providers/imap/#what-autodetection-checks)); this can take a few seconds.

> **Check:** the dialog shows the password form, titled **Connect** and the provider or domain.

> **If it did not work:** **Enter a full email address** means the address is incomplete. Use
> the form `name@example.com`.

### 2. Check the server settings

If the dialog shows a note such as "No published settings were found for this domain. These
server names are a guess; check them with your mail provider.", open **Server settings** and
compare with your provider's help page:

| Field | What to enter |
|---|---|
| **Username** | Usually your full email address (the default). Some hosts use a separate login name. |
| **Incoming (IMAP)** | Server name, port and security, for example `imap.example.com`, `993`, **TLS**. |
| **Outgoing (SMTP)** | Server name, port and security, for example `smtp.example.com`, `587`, **STARTTLS**. |

> **Check:** host names, ports and security match your provider's documentation.

> **If it did not work:** if your provider publishes no settings, ask them, or look at the
> account settings of another mail app that already works.

### 3. Enter the password and connect

Enter the **Password** (or **App password** when the provider needs one; many do with two-step
verification), optionally **Your name on outgoing mail**, and click **Connect**. The button
shows **Checking the connection…** while the Hub signs in to the IMAP server and connects to
the SMTP server. Nothing is saved unless both work.

> **Check:** the dialog shows **you@example.com is connected**, and **Settings → Mailboxes**
> shows the mailbox downloading mail.

> **If it did not work:** the dialog names the problem; see [Troubleshooting](https://docs.posternmail.app/providers/imap/#troubleshooting).
> After a connection error it opens **Server settings** for you.

## Ports and security

| Security | Meaning | Usual ports |
|---|---|---|
| **TLS** | Encrypted from the first byte (implicit TLS) | IMAP 993, SMTP 465 |
| **STARTTLS** | Starts unencrypted, then upgrades to TLS. The Hub refuses to continue if the upgrade fails. | IMAP 143, SMTP 587 |
| **None** | No encryption. Your password and mail travel in clear text. | IMAP 143, SMTP 25 or 587 |

Use **TLS** or **STARTTLS**. **None** is meant for a test server on the same machine; the Hub
writes a warning to its log when it is used with any other host. The Hub uses TLS 1.2 or newer
and checks the server's certificate against the host name you entered.

Match the port to the security setting. 993 with **STARTTLS**, or 587 with **TLS**, fails with
a timeout or a "secure connection" error.

The Hub signs in with `AUTH PLAIN` (or `LOGIN` when the server offers nothing else) over the
encrypted connection. A server that only offers OAuth for IMAP (like Gmail and Microsoft without
an app password) cannot be used with a password.

## Self-signed certificates

The app has no switch to accept an invalid or self-signed certificate. A server with such a
certificate fails with **Can't make a secure connection to the mail server at …**. What to do:

- **Best:** give the server a real certificate, for example from Let's Encrypt, and use the host
  name it was issued for.
- **Proton Mail Bridge** is the exception: the Hub turns certificate checking off for it
  automatically, because Bridge always uses its own certificate on your own machine.
- The Hub's API accepts `"insecureSkipVerify": true` per server when adding a password mailbox
  (`POST /api/v1/mailboxes`, see the [API reference](https://docs.posternmail.app/reference/api/)). Use it only for a
  server on a network you trust: without the check, anyone on the path can pretend to be the
  server and read your password.

## What autodetection checks

When you type your address, the Hub tries these in order and uses the first answer:

1. **Built-in list**: the providers in the table above, plus Gmail, Outlook.com, iCloud, Yahoo,
   AOL and Fastmail.
2. **MX records** of your domain, to recognize domains hosted by Google Workspace,
   Microsoft 365, iCloud+, Fastmail, Zoho, mailbox.org or Proton.
3. **Published settings**, all fetched at once, each with a short timeout (4 seconds):
   - Mozilla's provider database for your domain (`https://autoconfig.thunderbird.net/v1.1/example.com`),
   - your domain's own autoconfig file at
     `https://autoconfig.example.com/mail/config-v1.1.xml` and
     `https://example.com/.well-known/autoconfig/mail/config-v1.1.xml` (with the placeholder
     address `user@example.com`, never yours),
   - Mozilla's provider database for the domain of your MX server (your host), skipping spam
     filter services such as Mimecast or Proofpoint,
   - DNS SRV records `_imaps._tcp`, `_imap._tcp`, `_submissions._tcp` and `_submission._tcp`
     (RFC 6186 and RFC 8314).
4. **MX guess**: `imap.` and `smtp.` on the domain of your MX server, when those names exist
   ("Mail for example.com is handled by host.example. These server names are a guess based on
   that; check them with your mail provider.").
5. **Plain guess**: `imap.example.com` (or `mail.example.com`) on 993 with TLS, and
   `smtp.example.com` (or `mail.example.com`) on 587 with STARTTLS.

The lookups only fetch public `https://` addresses: the Hub does not probe your LAN, follows at
most three redirects and reads at most 256 KB. Results are kept for an hour per domain (guesses
for 10 minutes). Autodetection never sends your address to anyone; Mozilla's database and your
domain only see the domain name.

For a server on your LAN, autodetection ends with a guess: enter the settings under **Server
settings** yourself. The connection itself may go to a LAN address.

## What the Hub does

- **Folders.** Every folder you can open is synced, inbox first and trash and spam last.
  Container folders that cannot hold mail are not synced. A namespace prefix such as
  `INBOX.` (Courier, Cyrus) is hidden.
- **Special folders** are found from the server's special-use flags (RFC 6154): `\Sent`,
  `\Drafts`, `\Trash`, `\Junk`, `\Archive`. Without them, the Hub goes by name, in many
  languages, for example:

  | Role | Names (examples) |
  |---|---|
  | Sent | Sent, Sent Items, Sent Messages, Sent Mail, Gesendet, Gesendete Objekte, Envoyés, Enviados, Inviati, Verzonden |
  | Drafts | Drafts, Draft, Entwürfe, Brouillons, Borradores, Bozze, Concepten |
  | Trash | Trash, Deleted, Deleted Items, Deleted Messages, Bin, Papierkorb, Corbeille, Papelera, Cestino |
  | Spam | Spam, Junk, Junk E-mail, Bulk Mail, Spamverdacht, Unerwünscht, Courrier indésirable |
  | Archive | Archive, Archives, Archiv, Archivo, Archivio, Archief |

  Archive moves mail to the archive folder and creates `Archive` if there is none.
- **New mail.** The Hub keeps a second connection in IMAP IDLE on the inbox, renewed every 25
  minutes, and syncs as soon as the server reports a change. All folders are checked every 2
  minutes. A server without IDLE is checked every 2 minutes only.
- **Changes** to read and flagged state come from CONDSTORE when the server supports it;
  otherwise the Hub compares recent messages every minute and whole folders every 6 hours.
- **Tags** are saved as IMAP keywords, when the server allows custom keywords.
- **Sending** goes through SMTP. The Hub then saves a copy in your Sent folder (except for
  Gmail, whose SMTP server does that itself). A server without SMTPUTF8 cannot send to
  addresses with non-ASCII characters.
- **Threads** are built from the `Message-ID`, `In-Reply-To` and `References` headers.
- **Devices.** The desktop and mobile apps connect to your server directly with the same
  settings and password, which the Hub hands them. The server must be reachable from those
  devices too, not only from the Hub.

## Change settings later

**Update sign-in** in **Settings → Mailboxes** only asks for a new password. To change the
server names, ports or username, remove the mailbox and add it again (nothing is deleted on the
server).

> [!NOTE]
> Developers can run a local test mail server, `go run ./cmd/devmail` in `hub/`. It is not
> meant for real mail. See [Development](https://docs.posternmail.app/development/).

## Troubleshooting

| Message | Cause | Fix |
|---|---|---|
| **The sign-in was rejected.** The server rejected the sign-in. Check the username and password. … | Wrong username or password, or the provider wants an app password. | Check **Username** (full address or login name). Create an app password if you use two-step verification. Some providers (GMX, WEB.DE, Zoho) need IMAP turned on first. |
| **The mail server didn't answer.** Couldn't connect to imap.example.com: the connection timed out. … | Wrong host or port, a port/security mismatch, or a firewall between the Hub and the server. | Check the pair (993 + TLS, 143 + STARTTLS). Test from the Hub's machine (below). |
| **The mail server didn't answer.** Check the server settings below and try again. | Connection refused, unknown host, certificate problem or SMTP failure. | Check the server names. If receiving works elsewhere but this fails, check the **Outgoing (SMTP)** settings: 465 = TLS, 587 = STARTTLS. |
| Mailbox shows **Can't make a secure connection to the mail server at …** | The certificate does not match the host name, has expired, or is self-signed. | Use the host name on the certificate, or see [Self-signed certificates](https://docs.posternmail.app/providers/imap/#self-signed-certificates). |
| Mailbox shows **Can't reach the mail server at … Trying again.** | Network problem or the server is down. | Wait; the Hub retries. If it lasts, test the connection from the Hub's machine. |
| Mailbox shows **This mailbox is full at the provider.** | The server reports the quota as exceeded. | Delete mail or buy more space at the provider. |
| Sending fails with "server does not support internationalized addresses" | The SMTP server lacks SMTPUTF8 and a recipient has non-ASCII characters. | Send to the ASCII form of the address, or use another server. |

To test from the Hub's machine (replace the host and port):

```sh
openssl s_client -connect imap.example.com:993 -servername imap.example.com
```

```sh
openssl s_client -starttls smtp -connect smtp.example.com:587 -servername smtp.example.com
```

A working server prints its certificate chain and a greeting such as `* OK` (IMAP) or `250`
(SMTP). A timeout means the port is blocked or wrong. With Docker, run the test inside the
container or from the host; both use the same network unless you changed it.
