# Connect iCloud Mail

> Connect iCloud Mail (icloud.com, me.com, mac.com and iCloud+ custom domains) with an app-specific password.

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

iCloud Mail works over IMAP and SMTP with an **app-specific password**, a separate password
that Apple creates for apps like Postern. This page covers `@icloud.com`, `@me.com` and
`@mac.com` addresses and custom domains on iCloud+.

## What you need

- An Apple Account with **two-factor authentication** (on for nearly all accounts).
- Your iCloud Mail address. Your Apple Account email is not always your iCloud Mail address:
  if you sign in to Apple with, say, a Gmail address, the mailbox to connect is your
  `@icloud.com` address. You find it on an iPhone under **Settings → (your name) → iCloud →
  iCloud Mail**, or in iCloud Mail on <https://www.icloud.com/mail>.

## 1. Create an app-specific password

1. Sign in at <https://account.apple.com/>.
2. Open **Sign-In and Security → App-Specific Passwords**.
3. Click **Generate an app-specific password** (or the **+** button), name it `Postern` and
   click **Create**. Enter your Apple Account password if asked.
4. Copy the password. It looks like `abcd-efgh-ijkl-mnop`. Apple shows it only once.

Apple's help: <https://support.apple.com/en-us/102654>.

> **Check:** the list under **App-Specific Passwords** contains `Postern`.

> **If it did not work:** if **App-Specific Passwords** is missing, two-factor authentication is
> off for your Apple Account. Turn it on first.

## 2. Add the mailbox

1. **Settings → Mailboxes → Add mailbox** and pick **iCloud**.
2. Type your iCloud Mail address and click **Continue**. The dialog goes straight to the
   password form. Its note says: "iCloud Mail needs an app-specific password: sign in at
   account.apple.com, open Sign-In and Security → App-Specific Passwords and create one. Your
   Apple Account must use two-factor authentication." **Create an app password** opens Apple's
   page.
3. Paste the app-specific password into **App password**. The dashes do not matter.
4. Optionally fill **Your name on outgoing mail**, then click **Connect**.

> **Check:** the dialog shows **you@icloud.com is connected**. **Settings → Mailboxes** shows
> **iCloud · Downloading mail, …% done**, then **Up to date**.

> **If it did not work:** see [Troubleshooting](https://docs.posternmail.app/providers/icloud/#troubleshooting).

### Custom domains (iCloud+)

If your own domain uses iCloud Mail (its MX records point to `*.mail.icloud.com`), the Hub
recognizes it and uses the same servers. Type the custom address in step 2. If iCloud refuses
the sign-in, open **Server settings** and set **Username** to your `@icloud.com` address: the
dialog notes "If signing in fails, use your @icloud.com address as the username."

You can also connect the `@icloud.com` address and add the custom addresses under **Settings →
Identities & signatures → Add an address**, so you can send from them.

## Server settings

The Hub fills these in.

| | Server | Port | Security |
|---|---|---|---|
| Incoming (IMAP) | `imap.mail.me.com` | 993 | TLS |
| Outgoing (SMTP) | `smtp.mail.me.com` | 587 | STARTTLS |
| Username | your iCloud Mail address | | |
| Password | the app-specific password | | |

Apple's reference: <https://support.apple.com/en-us/102525>.

## What the Hub does with iCloud

- **Sync** over IMAP. Inbox, Sent Messages, Drafts, Archive, Deleted Messages and Junk are
  recognized by their special-use flags or names.
- **New mail** arrives at once through IMAP IDLE on the inbox. All folders are checked every
  2 minutes.
- **Sending** goes through `smtp.mail.me.com`. The Hub then saves a copy in your Sent folder.
- **Tags** are saved as IMAP keywords when the server allows them.
- **Devices.** The desktop and mobile apps connect to iCloud directly with the same app-specific
  password, which the Hub hands them.

## Limits

- Apple limits how much mail an iCloud account can send per day and how many recipients a
  message can have. Postern does not change those limits.
- Changing your Apple Account password revokes all app-specific passwords. The mailbox then
  shows **The sign-in no longer works**: create a new one and **Reconnect**.
- Apple allows a limited number of active app-specific passwords. Revoke the ones you no
  longer use.

## Troubleshooting

| Symptom | Cause | Fix |
|---|---|---|
| **The sign-in was rejected.** | You used your Apple Account password, the app-specific password was revoked, or the username is wrong. | Create a new app-specific password. For a custom domain, set **Username** to your `@icloud.com` address. |
| **The sign-in was rejected** although the password is new | The address is your Apple Account email, not your iCloud Mail address. | Use your `@icloud.com` address. |
| **The mail server didn't answer.** | The Hub cannot reach `imap.mail.me.com` or `smtp.mail.me.com`. | Check the Hub's internet access and that outgoing ports 993 and 587 are open. |
| The mailbox shows **The sign-in no longer works** | You changed your Apple Account password or revoked the app-specific password. | Create a new one and **Reconnect**. |
| Sending from a custom address fails | The address is not set up in iCloud Mail. | Add it in iCloud Mail settings first, then under **Settings → Identities & signatures**. |

To disconnect, remove the mailbox in Postern and revoke the app-specific password at
<https://account.apple.com/> (**Sign-In and Security → App-Specific Passwords**).
