E-mail: "Sending method" is an explicit choice - IWSN (built-in), Own SMTP server, Microsoft Graph (deprecated)

What is chosen is what is used. The choice is the stored field `emailMethod` of Site integrations (empty until
somebody chooses); `emailTransport` of 1.6 - 1.17.0 stays, hidden.

- no silent switch: a chosen method that cannot be used (SMTP incomplete, Graph without GRAPH_*) fails loudly
  - status smtp-incomplete / graph-not-set-up, state block, doctor mail-method - and nothing is sent another way
- upgrade writes nothing and loses no mail: until somebody chooses, the order of 1.17.0 applies and the field
  shows its result as selected; the first save of the panel's form stores the choice
- only the chosen method's fields are shown; the test e-mail names the method (Graph too)
- mail: { relay: false } does not offer "IWSN" (the stored values stay three: one SQL enum for every project)
- Postgres / SQLite: one migration (a column). Before it runs the plugin's readers read the global without the
  field, mail goes the old way, one loud log line and the doctor say what to do
- getMailMethod, setMailMethod, resolveMailMethod, readMailSettings, mailMethodColumnMissing exported
- tests on SQLite, Postgres and MongoDB, with and without the migration; docs, AGENT.md, skills, changelog

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-26 22:39:03 +01:00
co-authored by Claude Fable 5.2
parent c6841a1674
commit ee8ea42956
26 changed files with 376 additions and 138 deletions
+16 -7
View File
@@ -11,7 +11,8 @@ once there are more than 20.
## 1.17.1 — security fixes from the IAWL review; the panel's sign-in look; the sending method is chosen
> **Read before upgrading.** No schema change, no migration on any database. In this order:
> **Read before upgrading.** **MongoDB: no migration. Postgres / SQLite: one migration** — a new column for the
> sending method (point 5). In this order:
>
> **1. A write-only secret could be read back (fixed).** On 1.17.0 an **admin** could recover the SMTP password or
> the Turnstile secret key character by character through a query that names the field
@@ -55,8 +56,11 @@ once there are more than 20.
> be used — "Own SMTP server" without server, user name and password, "Microsoft Graph" on a server without
> `GRAPH_*` — e-mails **fail and the panel says so; they are not sent another way** (in 1.17.0 they would have gone
> through SMTP or IWSN). So after the upgrade: open the tab, check that the method shown is the one meant, save.
> No schema change: the choice is kept in `payload-kv`. A seed or script that set `emailTransport` keeps working
> (it leaves the site on the old order); to choose, it writes `emailMethod`.
> **Postgres / SQLite projects: create and apply one migration** (`pnpm payload migrate:create`; the new field
> `emailMethod` is a column) in the same deploy. Without it the site still sends its mail the old way and one loud
> log line says so, but the Site integrations page of the panel does not open. MongoDB: nothing.
> A seed or script that set `emailTransport` keeps working (it leaves the site on the old order); to choose, it
> writes `emailMethod`.
### Security
- **Write-only secrets cannot be named in a query** (point 1 above). `secretReadAccess`, the field read rule behind
@@ -148,10 +152,11 @@ once there are more than 20.
shown; the state block and the test e-mail name it ("through IWSN" / "through your SMTP server" / "through
Microsoft Graph"). A chosen method that cannot be used fails loudly — status `smtp-incomplete` /
`graph-not-set-up`, doctor `mail-method` — and the mail is not sent another way; in 1.17.0 "Automatic" picked
the transport from which fields were filled in. Stored without a schema change: the field `emailMethod` is
virtual, the choice is in `payload-kv` (`MAIL_METHOD_KV_KEY`); `emailTransport` stays, hidden.
New exports: `getMailMethod`, `setMailMethod`, `resolveMailMethod`, `isMailMethod`, `MAIL_METHODS`,
`MAIL_METHOD_KV_KEY`, types `MailMethod`, `ResolvedMailMethod`, `MailMethodProblem`. `pnpm payload generate:types`
the transport from which fields were filled in. Stored in a new field of Site integrations, `emailMethod`
(`relay` / `smtp` / `graph`, empty until somebody chooses); `emailTransport` stays, hidden.
New exports: `getMailMethod`, `setMailMethod`, `resolveMailMethod`, `readMailSettings`, `isMailMethod`,
`MAIL_METHODS`, `STORED_MAIL_METHOD_CONTEXT`, `mailMethodColumnMissing`, types `MailMethod`, `ResolvedMailMethod`,
`MailMethodProblem`. `pnpm payload generate:types`
gives a diff (the new field): run it and commit.
- `AdminLogo` prints the sign-in panel when the plugin gives it `signIn` (the default with `whiteLabel`); wired by
hand without that prop it is the plain logo as before. The logo on the login screen is now shown inside
@@ -164,6 +169,10 @@ once there are more than 20.
- `truncate` (summaries, meta descriptions) never returns more than its limit.
### Requires project changes
- **Postgres / SQLite projects: one migration**, in the same deploy — the new field `emailMethod` of Site
integrations is a column (`pnpm payload migrate:create`, commit, apply at container start). MongoDB projects:
nothing. Until it runs: mail keeps going the old way, the Site integrations page does not open,
`iapl-doctor --deep` reports `mail-method` (point 5 above).
- **The proxy matcher**, one line (point 4 above).
- **A config value the plugin does not understand** stops the start (point 2): `pnpm build` before deploying.
- **Recommended with `whiteLabel`:** `signIn: { allScreens: true }` + `pnpm payload generate:importmap`; look at a