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:
co-authored by
Claude Fable 5.2
parent
c6841a1674
commit
ee8ea42956
+21
-10
@@ -54,16 +54,27 @@ SMTP server, port, user name and password under "Own SMTP server"; the service's
|
||||
panel's SMTP server when one is filled in ("Attachments" below).
|
||||
- `mail: { relay: false }` takes the option "IWSN" away; a choice of it stored earlier then counts as no choice.
|
||||
|
||||
**Where the choice is stored.** In Payload's key-value store (`payload-kv`, key `MAIL_METHOD_KV_KEY`), not in a
|
||||
column: the panel's field `emailMethod` is **virtual**. So **no SQL schema changes and no migration exists** —
|
||||
a third value in the stored select `emailTransport` (`smtp` / `graph` since 1.6) would have changed the Postgres
|
||||
enum, and could still not tell "SMTP was chosen" from the `smtp` every site has stored since before there was a
|
||||
choice. `emailTransport` stays, hidden in the panel, and follows the choice where it can say it (`graph`, else
|
||||
`smtp`). From code: `getMailMethod(payload)` (`'relay' | 'smtp' | 'graph' | null`), `setMailMethod(payload, method)`
|
||||
(a seed or a deploy script; `null` = nobody has chosen), `payload.updateGlobal({ slug: 'site-integrations', data: {
|
||||
emailMethod: 'smtp' } })`, `resolveMailMethod(settings, { chosen, graphEnv, relay })` →
|
||||
`{ method, explicit, problem? }` (types `MailMethod`, `ResolvedMailMethod`, `MailMethodProblem`; `MAIL_METHODS`,
|
||||
`isMailMethod`).
|
||||
**Where the choice is stored.** In the global's own field **`emailMethod`** (a select: `relay` = IWSN, `smtp`,
|
||||
`graph`), new in 1.17.1 and **empty until somebody chooses**. The field of 1.6 – 1.17.0, `emailTransport`
|
||||
(`smtp` / `graph`), stays, hidden in the panel, and follows the choice where it can say it (`graph`, else `smtp`).
|
||||
A field of its own, not a third value there: every site has `smtp` stored in `emailTransport` from before there was
|
||||
a choice, so "SMTP was chosen" could not be told from "nothing was chosen". From code: `getMailMethod(payload)`
|
||||
(`'relay' | 'smtp' | 'graph' | null`), `setMailMethod(payload, method)` (a seed or a deploy script; `null` = nobody
|
||||
has chosen), `payload.updateGlobal({ slug: 'site-integrations', data: { emailMethod: 'smtp' } })`,
|
||||
`resolveMailMethod(settings, { chosen, graphEnv, relay })` → `{ method, explicit, problem? }` (types `MailMethod`,
|
||||
`ResolvedMailMethod`, `MailMethodProblem`; `MAIL_METHODS`, `isMailMethod`). **A read shows the method in effect**
|
||||
in `emailMethod` (that is what the panel selects); the stored value itself — empty when nobody chose — comes from
|
||||
`getMailMethod`, or from `readMailSettings(payload)` / a read with `context: { [STORED_MAIL_METHOD_CONTEXT]: true }`.
|
||||
|
||||
**Postgres and SQLite: one migration. MongoDB: nothing.** The field is a new column (`email_method`, with its
|
||||
enum on Postgres): `pnpm payload migrate:create`, commit the migration, and have it applied when the new container
|
||||
starts ([deployment.md](./deployment.md) §4.3). **Before it has run** the site does not go down: the plugin's own
|
||||
readers (`getSiteIntegrations`, the mail adapter, Turnstile, analytics) notice the missing column, read the global
|
||||
without that field, and one loud line in the server log says what to do; e-mails go the way they did before the
|
||||
upgrade. What does not work until the migration: the **Site integrations page of the panel** (Payload's own read
|
||||
fails), every write to the global — the sending status is not recorded — and choosing the method.
|
||||
`mailMethodColumnMissing()` and the doctor's deep run (`mail-method`, error) report it. A running process looks for
|
||||
the column again within a minute.
|
||||
|
||||
**Until somebody chooses — a site upgraded from 1.17.0 or older, and a new site.** Nothing is written on upgrade.
|
||||
The method follows the order of 1.17.0, the field shows it **as selected**, and mail keeps leaving the way it did
|
||||
|
||||
Reference in New Issue
Block a user