# SMTP and IMAP

URL: https://zerodev.ca/docs/oasis/developer-documentation/servers

> How Oasis receives, accepts and serves mail.



## SMTP

The `smtp` handler in `core` runs up to three listeners. Its settings are in the `smtp` config group.

| Listener             | Sign in                  | Accepts                                                            |
| -------------------- | ------------------------ | ------------------------------------------------------------------ |
| Inbound, port 25     | Not offered              | Mail for local domains only. Anything else is refused as relaying. |
| Submission, port 587 | Required, after STARTTLS | Mail from a mailbox, sent as one of its own addresses or aliases.  |
| Secure, port 465     | Required                 | Same as 587, over TLS from the start.                              |

Inbound mail is checked with SPF, DKIM and DMARC. A DMARC `reject` policy failure is refused when `reject_dmarc` is on, and a `quarantine` failure goes to Junk. The results are added as an `Authentication-Results` header.

Submitted mail gets `Date` and `Message-ID` headers when missing, is handed to `outbound.send` and a copy is saved to Sent.

SMTP replies are phrases in the core `smtp` lang package, so they can be translated or reworded from the dashboard.

## IMAP

The `imap` handler in `core` is an IMAP4rev1 server written for Oasis. Its settings are in the `imap` config group. Mail apps sign in with the mailbox address and password.

| Capability                 | Notes                                                                      |
| -------------------------- | -------------------------------------------------------------------------- |
| `IDLE`                     | Pushes new mail, expunges and flag changes as they happen.                 |
| `UIDPLUS`                  | `APPENDUID` and `COPYUID` codes.                                           |
| `MOVE`                     | Moves keep their size and update the quota once.                           |
| `SPECIAL-USE`              | Sent, Drafts, Junk, Trash and Archive are flagged in `LIST`.               |
| `LITERAL+`, `SASL-IR`      | Fewer round trips for sign in and `APPEND`.                                |
| `AUTH=PLAIN`, `AUTH=LOGIN` | Only after TLS. Port 143 offers `STARTTLS` and `LOGINDISABLED` until then. |

`FETCH` supports `ENVELOPE`, `BODYSTRUCTURE`, `BODY[...]` sections including `HEADER.FIELDS` and partial ranges, and the `RFC822` forms. `BODY[...]` sets `\Seen`, `BODY.PEEK[...]` does not. `SEARCH` supports flags, dates, sizes, addresses, subject, header, body and text keys with `NOT` and `OR`.
