# The prod `mailtest` project A live `ctx.mail` exercise running on the production server, against a real mail provider. It exists because every other test in this repo runs against a fake server on the dev host, and a fake cannot show what a provider actually does. `mailprobe.js` is the function as deployed. Keep it in the repo so the next person can see what was tested rather than rediscovering it. ## Layout - project `mailtest` on prod - secrets `MAIL_IMAP_PASSWORD` and `MAIL_SMTP_PASSWORD`, set over `PUT /api/v1/projects/mailtest/secrets/{name}` - one http function `mailprobe`, route `/mail/:op`, reached at `/fn/mailtest/mail/` **No credential is in the source.** `userSecret`/`passwordSecret` name the project secrets and the host resolves them, so neither this file nor an echoed options object can leak one. `timeoutMs: 15000` is needed: the default wall budget is 2 s and a TLS IMAP session plus a LOGIN does not fit in it. ## The ops | op | what it proves | |---|---| | `mailboxes` | LIST works and modified UTF-7 is decoded | | `read` | a plain read of this mailbox EXCEEDS the 4 MiB per-run cap | | `small` | `smallerThanBytes` is the documented remedy for that, and it works | | `unseen` | a structured `criteria` object | | `accents` | a non-ASCII criterion is REFUSED, not sent | | `send` | SMTP over STARTTLS on 2525 | | `roundtrip` | send to the readable mailbox, then fetch it back and assert bytes | ## What this found that the fakes did not - **`mail_too_large` carried two different statuses** (413 transport, 422 per-run cap) while the docs promised 413. Fixed: 422 everywhere. - **A returned object containing `status`, `headers` or `body` is read as a response ENVELOPE** and may hold nothing else, so a diagnostic field named `status` fails the run with `invalid_return` - and inside a `catch` it hides the error it was reporting. - **`header` is raw and FOLDED.** A long accented subject arrives as `Subject: =?UTF-8?B?...?= =?UTF-8?B?...?=`, with nothing on the `Subject:` line. The obvious regex finds an empty subject; the next-obvious one silently captures only the FIRST encoded word. See task #59. - **Port 2525 was never blocked by the host.** An earlier note said DigitalOcean blocked 25, 465, 587 and 2525; it blocks the first three. 2525 simply had nothing listening when it was measured, and was folded into the block without the second host that would have distinguished them. ## Confirmed in production A send is accepted in ~1.3 s; the message is then found by `UID SEARCH` and fetched back carrying `\Recent` and **not** `\Seen`, which is `BODY.PEEK` proven against a genuinely new message. The lone `.` line survives and is not doubled, quoted-printable is applied (the body shows `stamp=3D`), the accented attachment filename uses RFC 2231, `multipart/mixed` is declared in the header with `multipart/alternative` inside, and a send over 587 fails as `mail_timeout` 504 with `retryable: false` after ~7 s - which is also live confirmation that connect is capped at HALF the run budget.