Mail relay: review of 7d766b6 — R-1 to R-12, four mutations, two sentences

- R-1 a delivered token becomes the one in use only on 200 or a refusal given after authentication
- R-2 a token of another site is refused by what /v1/status says (access-key field, scripts); docs for staging
- R-3 the confirm route looks the nonce up first and counts only refused calls
- R-4 one budget of time per message (10 s, 30 s with files), enrolment and retries included
- R-5 'Disconnect' without the service's answer is not confirmed and keeps the token to try again
- R-6 no enrolment without the confirm route in the config
- R-7 half an SMTP set-up: one log line and a hint in the panel
- R-8 to R-10, R-12 docs; R-11 the last failure stays in the state block
- tests for redirect: manual, the candidate's nonce, the expectation taken back, one recipient only

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-25 22:07:10 +01:00
co-authored by Claude Fable 5.2
parent 0ee74ab2a4
commit a2b07b1dc1
23 changed files with 584 additions and 69 deletions
+8 -3
View File
@@ -27,7 +27,9 @@ once there are more than 20.
> `relay-unreachable` and sends nothing, as it sent nothing before.**
### Requires project changes
- **Nothing has to be run.** The e-mail tab of Site integrations has a new block ("How e-mails are sent"); it is
- **A CI that compares generated types:** `payload generate:types` gives a diff on upgrade — four field descriptions
of Site integrations changed (no type did). Run it and commit `payload-types.ts`. The import map does not change.
- **Nothing else has to be run.** The e-mail tab of Site integrations has a new block ("How e-mails are sent"); it is
rendered by the status banner already in every import map, so `generate:importmap` gives no diff. No field was
added; "Sending method" keeps its two stored values.
- **What changes for an existing site on upgrade — e-mail:**
@@ -39,6 +41,7 @@ once there are more than 20.
| `GRAPH_*` set, "Sending method" on SMTP, no SMTP server (mail failed until now) | Mail goes through Graph | fill in SMTP, or remove the variables |
| Neither (mail failed until now with "not configured") | **An outbound call:** on the next e-mail the site enrols with the service — `POST https://webservices.intecion.net/mail/v1/enrol` with its host and the plugin version — and then sends through it, from `[email protected]`. A host Intecion has not listed waits for approval first | `iapl({ mail: { relay: false } })` |
| Any site with the mail service enabled (the default) | **A new public route:** `POST /api/iapl/mail-relay/confirm` — answers `404` and changes nothing unless the site itself started an enrolment in the last 5 minutes; rate-limited. Three admin-only routes beside it (`…/status`, `…/connect`, `…/disconnect`) | `mail: { relay: false }` removes all four |
| SMTP **half** filled in — a server or a user name, but not server, user name and password (until now: refused, "Fill in the server, user name and password") | Sent through the mail service; one line in the server log and a hint in the state block say that the SMTP settings are incomplete | complete or empty the SMTP fields; `mail: { relay: false }` |
| "Microsoft Graph" chosen in the panel but `GRAPH_*` missing (until now: SMTP with a warning) | SMTP if filled in, otherwise the mail service | as above |
| A site on `localhost` or without `serverURL` | Refused by the plugin itself; nothing leaves the machine. Development: SMTP (a local catcher) as before | — |
@@ -90,13 +93,15 @@ once there are more than 20.
the site's server addresses and to the host it was issued for (a database copied to another host enrols as itself),
rotated every 90 days, healed by re-enrolment. One message = one `Idempotency-Key` and
one encoding across at most three attempts; a send with no answer is reported as **not confirmed** (it may be out)
and cannot double when sent again. Every message says what it is (form notification, form confirmation, account,
and, while the same process runs, goes out under the same key when sent again (after a restart or from another
instance a repeat is a new message). One message has one budget of time — 10 seconds, 30 with files
(`mail.relay.totalTimeoutMs`) — so a service that hangs does not hold a form's visitor for the sum of the attempts. Every message says what it is (form notification, form confirmation, account,
test, system): form mail and Payload's "forgot password" are marked by the plugin; `withMailKind` /
`runWithMailKind` for a project's own. Account mail is limited by the site itself (5 an hour to one address, 10 by
one visitor; `mail.relay.accountMail`). Limits and the file size come from the service (30 an hour, 200 a day, 10 MB
unless Intecion set others); `mailAttachmentLimit` reports the latter.
- **Plugin option `mail`**: `mail: { relay: false | { url, host, enrol, token, senderName, kind, accountMail,
confirmRateLimit, timeoutMs, retryBackoffMs, fetchImpl }, graphDeprecationWarning }`; `mailAdapter({ relay })`.
confirmRateLimit, totalTimeoutMs, timeoutMs, retryBackoffMs, fetchImpl }, graphDeprecationWarning }`; `mailAdapter({ relay })`.
- **Panel:** the state block on the e-mail tab (transport in effect, the site's state with the service, sender and
reply address, what is left of the limits, a replaced sender name; "Check now", "Connect again", "Disconnect",
"Enter an access key"); "Sending method" reads "Automatic" / "Microsoft Graph (deprecated)"; the server field reads