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

# Read and Sync Your Mailbox via IMAP on UGMail (Port 993)

> Connect to UGMail's IMAP server at mail.ugmail.co:993 with SSL/TLS for full two-way mailbox sync with any email client or custom application.

IMAP (Internet Message Access Protocol) is the standard protocol for reading and organizing email while keeping messages stored on the server. Unlike POP3, IMAP keeps your client and mailbox in sync — actions you take in one client (reading, moving, deleting, flagging) are reflected everywhere else. Use IMAP when you need live access to a mailbox from multiple devices, a desktop email client, or a custom application that monitors incoming messages.

## Connection settings

Configure your IMAP client with the following details:

| Setting  | Value                      |
| -------- | -------------------------- |
| Server   | `mail.ugmail.co`           |
| Port     | `993`                      |
| Security | SSL/TLS                    |
| Username | Your mailbox email address |
| Password | Your mailbox password      |

## Authentication

Use your mailbox's full email address as the username (e.g. `alice@example.com`) and the password you set via the `secrets` field in the Management API as the password. The same credentials work across IMAP, SMTP, POP3, and all other UGMail protocols.

## Compatible email clients

UGMail's IMAP server is compatible with any standards-compliant email client, including:

* **Mozilla Thunderbird** (Windows, macOS, Linux)
* **Apple Mail** (macOS, iOS)
* **Microsoft Outlook** (Windows, macOS)
* **Gmail app** (iOS, Android — via "Add other account")
* **mutt / neomutt** (terminal)
* **K-9 Mail** (Android)
* **Spark**, **Airmail**, **Canary Mail**, and other third-party clients

## Configuring an email client

The exact steps differ by client, but the following sequence applies to virtually every IMAP-capable application.

<Steps>
  <Step title="Open account settings">
    In your email client, navigate to **Settings** (or **Preferences**) and choose **Add Account** or **Add Mail Account**.
  </Step>

  <Step title="Enter your account details">
    Provide your name, your full mailbox email address, and your mailbox password when prompted.
  </Step>

  <Step title="Choose manual / custom setup">
    If your client offers automatic configuration, skip it and select **Manual setup** or **Custom** so you can enter the UGMail server details directly.
  </Step>

  <Step title="Enter incoming server settings">
    Set the incoming mail server to `mail.ugmail.co`, port `993`, with **SSL/TLS** encryption.
  </Step>

  <Step title="Enter outgoing server settings">
    Set the outgoing (SMTP) server to `mail.ugmail.co`, port `587`, with **STARTTLS** encryption. Use the same email address and password for SMTP authentication.
  </Step>

  <Step title="Save and verify">
    Save the account. Your client will connect and begin syncing your inbox. If the connection fails, double-check the server address, port, security type, and credentials.
  </Step>
</Steps>

## Code example

Use Python's built-in `imaplib` to connect programmatically, search your inbox, and read messages.

```python Python (imaplib) theme={null}
import imaplib

imap = imaplib.IMAP4_SSL('mail.ugmail.co', 993)
imap.login('alice@example.com', 'SecurePassword123!')
imap.select('INBOX')

_, messages = imap.search(None, 'ALL')
for num in messages[0].split():
    _, data = imap.fetch(num, '(RFC822)')
    print(data[0][1].decode())

imap.logout()
```

The `imap.search(None, 'ALL')` call returns the IDs of every message in the selected folder. You can replace `'ALL'` with any valid IMAP search criterion — for example, `'UNSEEN'` to fetch only unread messages, or `'FROM "sender@example.com"'` to filter by sender.

## Troubleshooting

<Warning>If you see an `AUTHENTICATE failed` error, confirm that your username is the full email address (not just the local part before the `@`) and that the password matches what you set in the `secrets` field of the Management API exactly.</Warning>

| Symptom                | Likely cause                               | Fix                                                                                       |
| ---------------------- | ------------------------------------------ | ----------------------------------------------------------------------------------------- |
| `Connection timed out` | Port 993 blocked by firewall               | Open outbound port 993, or check with your network administrator                          |
| `Certificate error`    | Client not trusting the server certificate | Ensure your client uses system trust store or update to a current certificate bundle      |
| Folders not syncing    | Client set to sync only INBOX              | Enable "Subscribe to all folders" or manually subscribe in your client                    |
| Slow initial sync      | Large mailbox, full RFC822 fetch           | Use `(BODY.PEEK[HEADER])` instead of `(RFC822)` to fetch headers only during initial scan |
