WIP: sending method as an explicit choice, kept in payload-kv (superseded: the choice moves to a stored field)

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-26 22:30:03 +01:00
co-authored by Claude Fable 5.2
parent 68a2555277
commit c6841a1674
34 changed files with 740 additions and 96 deletions
+22 -1
View File
@@ -9,7 +9,7 @@ versions at once, go through every "Requires project changes" section in order,
version you have. A new release = a new section at the top; we remove the oldest ones only
once there are more than 20.
## 1.17.1 — security fixes from the IAWL review; the panel's sign-in look
## 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:
>
@@ -46,6 +46,17 @@ once there are more than 20.
> **4. One line in each project:** the proxy matcher (`src/proxy.ts`) —
> `'/((?!(?:api|admin|_next)(?:/|$)|.*\\..*).*)'`; `iapl-doctor` warns `proxy-matcher` until it is changed. Without it
> pages whose names only start with `api` / `admin` / `_next` skip the proxy, as before.
>
> **5. E-mail — nothing to do, one thing to know.** "Sending method" in Site integrations → E-mail sending is a
> choice again: IWSN (built-in), Own SMTP server, Microsoft Graph (deprecated). **Upgrading writes nothing and
> loses no mail:** the field shows the method the site sends through today as selected (no SMTP server → IWSN; an
> SMTP server → Own SMTP server; `GRAPH_*` → Microsoft Graph), and the site keeps sending that way. **The first save
> of Site integrations stores that choice; from then on the site sends that way only.** If the chosen method cannot
> 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`.
### Security
- **Write-only secrets cannot be named in a query** (point 1 above). `secretReadAccess`, the field read rule behind
@@ -132,6 +143,16 @@ once there are more than 20.
the e-mail — every account may change its own e-mail (security.md).
### Changed
- **E-mail: "Sending method" is an explicit choice again** — "IWSN (built-in)", "Own SMTP server", "Microsoft
Graph (deprecated)" — and what is chosen is what is used (point 5 above). Only the chosen method's fields are
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`
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
240 × 72 px (it was up to 420 × 120).
+17 -6
View File
@@ -1257,7 +1257,7 @@ add missing hosts with flags / `extra`; (3) change `mode` to `'enforce'` in both
| Sitemap split / CDN cache / memo | `sitemapOptions: { maxUrls: Infinity, cacheControl: false, memoSeconds: 0 }` | `sitemapEntries`, `createSitemapRouteHandler`, `buildSitemapIndexXml`, `buildSitemapEntries` |
| Sitemap error = 503 + `Retry-After` | — (correct HTTP behaviour) | your own route with `buildSitemapXml` |
| IndexNow silent with `IAPL_NOINDEX` | `indexNow` off by default | `submitToIndexNow` by hand |
| A site with no SMTP server in the panel sends through the Intecion mail service: it enrols by itself on its first send (an outbound call with its host and the plugin version) and gets its own token through the public route `POST /api/iapl/mail-relay/confirm` | `mail: { relay: false }` (no call, no routes, no state block) | `mail.relay: { url, host, enrol, token, senderName, kind, accountMail, confirmRateLimit, timeoutMs, retryBackoffMs, fetchImpl }`; `mailAdapter({ relay })`; §7.2 |
| A site sends through the Intecion mail service unless an admin chose another "Sending method" (SMTP, Graph): it enrols by itself on its first send (an outbound call with its host and the plugin version) and gets its own token through the public route `POST /api/iapl/mail-relay/confirm` | `mail: { relay: false }` (no call, no routes, no state block) | `mail.relay: { url, host, enrol, token, senderName, kind, accountMail, confirmRateLimit, timeoutMs, retryBackoffMs, fetchImpl }`; `mailAdapter({ relay })`; §7.2 |
| The mail service's token is kept in `payload.kv` (never in a field, never readable over REST or GraphQL), bound to the site's server addresses, rotated every 90 days | "Disconnect" in the panel; `disconnectRelay` | `enrolRelay`, `rotateRelayToken`, `setRelayToken`, `getRelayStatus` |
| Account e-mails through the mail service: at most 5 to one address and 10 asked for by one visitor an hour | `mail: { relay: { accountMail: false } }` | `accountMail: { perAddress, perVisitor, windowMinutes }` |
| Every message says what it is (form notification, form confirmation, account, test, system) | — (other transports ignore the mark) | `withMailKind`, `runWithMailKind`, `expectMailTo`, `mail.relay.kind`, `buildFormMailKindHook` |
@@ -1289,9 +1289,20 @@ No env variable, no key, no field to fill in, no import-map change (the tab's st
banner that is already in every import map). **Do not** add `nodemailer`, `resend`, an `api/send` route or a
`GRAPH_*` variable to a project.
**How a send is routed** (`resolveMailTransport`, type `MailTransport`): Microsoft Graph when the panel says so and
`GRAPH_*` is set (deprecated) → SMTP when server, user name and password are filled in → Graph when `GRAPH_*` is set →
the mail service → nothing (`mail: { relay: false }` and no SMTP). A site with SMTP filled in never contacts the service.
**How a send is routed** — by the admin's choice, Site integrations → E-mail sending → **"Sending method"**: "IWSN
(built-in)" (the mail service), "Own SMTP server", "Microsoft Graph (deprecated)". What is chosen is what is used;
a choice that cannot be used (SMTP incomplete, Graph without `GRAPH_*`) **fails loudly and nothing is sent another
way** (state block, status `smtp-incomplete` / `graph-not-set-up`, doctor `mail-method`). The choice is kept in
`payload-kv` (`MAIL_METHOD_KV_KEY`); the panel's field `emailMethod` is virtual, so **no schema change and no
migration**. Until somebody chooses (an upgraded site, a new site) the order of 1.17.0 applies and the field shows
its result as selected (`resolveMailTransport`, type `MailTransport`): Graph when `emailTransport` is `graph` and
`GRAPH_*` is set → SMTP when server, user name and password are filled in → Graph when `GRAPH_*` is set → the mail
service → nothing. The first save of Site integrations stores the choice. From code: `getMailMethod`,
`setMailMethod(payload, 'relay' | 'smtp' | 'graph' | null)`, `resolveMailMethod` (`ResolvedMailMethod`,
`MailMethodProblem`), `MailMethod`, `MAIL_METHODS`, `isMailMethod`; or `updateGlobal` with `emailMethod`. Seeds that
set up mail write `emailMethod`, not `emailTransport`. **Verify:** the state block names the method; **Send test
e-mail** answers "through IWSN" / "through your SMTP server" / "through Microsoft Graph"; `iapl-doctor --deep`
reports no `mail-method` finding after the first save. `mail: { relay: false }` removes the option "IWSN".
**What the site needs for the mail service** — check each one:
@@ -1324,8 +1335,8 @@ the mail service → nothing (`mail: { relay: false }` and no SMTP). A site with
--deep --url <site>` reports no `mail-*` finding. On `localhost` the plugin refuses to enrol (nothing leaves the machine): test
mail locally with SMTP (Mailpit) or `createFakeRelay()`.
**The client wants its own mail server:** fill in "Own SMTP server", user name, password and "Sender address" in the
panel, send a test. Nothing in code. **A site on `GRAPH_*`:** keeps working, warns once per start; move it when the
**The client wants its own mail server:** "Sending method" → "Own SMTP server", fill in server, user name, password
and "Sender address", save, send a test. Nothing in code. **A site on `GRAPH_*`:** keeps working, warns once per start; move it when the
owner says so (email.md "Moving off Microsoft Graph").
**Your own mail** goes through `payload.sendEmail`. Say what it is when it is not a generic system message:
+1 -1
View File
@@ -1244,7 +1244,7 @@ const payload = await getPayload({ config })
await payload.updateGlobal({
slug: 'site-integrations',
context: { ipalIntegrationStatus: true },
data: { emailStatus: { checkedAt: null, code: null, message: null, since: null, state: null }, emailTransport: 'smtp', smtpFromAddress: 'site@example-studio.test', smtpFromName: 'Example Studio', smtpHost: null, smtpPassword: null, smtpUser: null } as never,
data: { emailStatus: { checkedAt: null, code: null, message: null, since: null, state: null }, emailMethod: 'relay', emailTransport: 'smtp', smtpFromAddress: 'site@example-studio.test', smtpFromName: 'Example Studio', smtpHost: null, smtpPassword: null, smtpUser: null } as never,
overrideAccess: true,
})
for (const key of await payload.kv.keys()) {
+2
View File
@@ -100,6 +100,8 @@ through this procedure. Ask only when you are missing something you cannot get y
| pixel before consent (consent-check) | script wired by hand (`<Script>`) | only through the panel → `<Analytics>` (GA/GTM/pixels) or `<ConsentScript>` (analytics.md, consent.md) |
| banner without styles | Tailwind does not scan the plugin | `@source` on `node_modules/@intecion/ipal-kit/dist/**/*.js` (path relative to the CSS file, PROGRAMISTA §2.5) |
| emails are not sent | no `email: mailAdapter()` / empty Emails tab of the form / the transport fails | Site integrations → E-mail sending: read the block "How e-mails are sent" and the banner's code, then **Send test e-mail**; rows below; email.md |
| e-mails are not sent; state block: "Your SMTP server is chosen, but its settings are incomplete" / "Microsoft Graph is chosen, but it is not set up on this server" (status `smtp-incomplete` / `graph-not-set-up`, doctor `mail-method` error) | the chosen "Sending method" cannot be used, and since 1.17.1 nothing is sent another way | fill in server, user name and password / set the `GRAPH_*` variables — or choose another method (IWSN needs nothing) and save |
| the site switched how it sends after a field or a variable changed | nobody has chosen the "Sending method" yet (doctor `mail-method` info): the site still picks by the order of 1.17.0 | Site integrations → E-mail sending: check the method shown, save |
| state block: "Not connected yet" on the production domain | no e-mail was sent yet | **Send test e-mail** (the site enrols on its first send) or "Connect again" |
| `relay-refused` / "The mail service could not reach this site at …" (cause `callback-failed`) | `unreachable` / `timeout`: firewall, private network, wrong public host in `serverURL`; `redirect`: `trailingSlash: true`, apex → `www`, a language redirect; `status`: route blocked, missing (`mail: { relay: false }`?) or another `routes.api`; `confirmation`: a proxy rewrites the answer | `curl -i -X POST https://<host>/api/iapl/mail-relay/confirm -d '{}' -H 'content-type: application/json'` must answer **404 with an empty body, no redirect**; fix `serverURL` / `mail.relay.host`, or ask Intecion to set the site's confirm address (path ending in `/confirm/` with trailing slashes); then "Connect again" (the site does not retry by itself for 15 min). email.md "When the site cannot be confirmed" |
| `relay-refused`, cause `host-not-allowed` / "This site has no public address yet" | the site runs on `localhost`, a private name, or `serverURL` is empty | expected in development (use SMTP / Mailpit there); in production set `serverURL` |
@@ -39,6 +39,7 @@ description: Complete map of everything @intecion/ipal-kit provides — every ia
| `accounts.firstUserRoute` | `'panel'` | which auth collections `POST /api/<slug>/first-register` answers for while they are empty: only the one the panel logs in with (the first account of a site → admin). Others get `403`, a second staff collection included, in any spelling of the URL (the plugin's own endpoint sits in front of Payload's); a collection whose own `create` allows an anonymous request keeps its route. With `access.firstUserAdmin: false` and a default role below the panel role, the default `panelRole` is not applied (logged) and an explicit one is refused at start | a list of slugs; `'all'` = Payload's behaviour |
| `accounts.password` | `{ minLength: 12 }` | when a password is SET on a staff collection (create, first-user screen, change, reset by e-mail; panel, API and Local API): at least `minLength` characters, not the account's e-mail address. Existing passwords are never checked — a shorter one keeps logging in | `{ minLength }`; `false` = Payload's rule (3 characters) |
| `secrets.writeOnly` | on | `smtpPassword` and `turnstileSecretKey` (Site integrations) are never returned: REST, GraphQL and the panel get `'********'` when a value is stored; a save with nothing / empty / the mask keeps it, a new value replaces it, `'[[clear]]'` removes it; the Local API with access control off reads the real value. The panel is the source of these secrets — no env variable. A restore of a version is masked too | `false` = returned to whoever may read the global, as before |
| "Sending method" (`emailMethod`, virtual; `getMailMethod` / `setMailMethod`) | nobody has chosen: the order of 1.17.0, shown as selected | `relay` (IWSN), `smtp`, `graph` (deprecated): what is chosen is what is used, no fallback; kept in `payload-kv`, no schema change |
| `secrets.reenterOnChange` | on | a save through access control that changes `smtpHost`, `smtpPort` or `smtpUser` while a password is stored must send the password again or remove it (`400` on the field otherwise), whatever `emailTransport` says — so an admin session cannot send the stored password to a server of its own. A change of the transport alone, and the Local API with access control off, are not asked | `false` = the stored password follows the new server |
| `dashboardAlerts` | `{ integrations: 'admin', cookies: 'editor' }` | who sees the plugin's dashboard alerts: integration details (error text, link) for `integrations` and above, a neutral "ask an administrator" for editors below it, nothing for others; the cookie crawl / approval alert for `cookies` and above. With a role, a session that owes its second factor sees none | `integrations: 'editor' | 'all'`, `cookies: 'all'` (`'all'` = as before: no role and no second factor is checked) |
| `adminRoute` | `'/admin'` | `config.routes.admin`; stats link and views, `IntegrationAlerts` | the project moves `app/(payload)/<route>/` itself and adds the route to the proxy matcher (security.md) |
+2 -2
View File
@@ -660,8 +660,8 @@ scaling (5). `●` routes for pages need the database at build time (PROGRAMISTA
in every language.
6. **Notifications**: form messages in every language.
7. **Site integrations → E-mail sending**: "Sender name" (the client's name; empty = the site name) and **"Sender
address"** (the client's address: with the mail service replies go there). SMTP fields **only** when the client asked
for its own server. On the production domain: the block "How e-mails are sent" must say "Connected to IWSN" ("waiting for approval": while the service runs with enrolment "pending" (from its launch until Intecion switches to open enrolment), every new site waits for approval — ask Intecion to approve the host; under open enrolment it is the exception; the real domain enrols by itself at launch although the site was connected on its development address — nothing to press; "The data comes from another site" = the site is non-public (its host matches `developmentHosts`, built in `*.dev.netscale.pl`, or `IAPL_NOINDEX=1`) and holds a copy of another site's data: press "Connect again" only if the copy should send — on the production domain it means `IAPL_NOINDEX` was left set. A development address under `*.dev.netscale.pl` needs nothing; a staging or test copy on any other host must have its host in `iapl({ developmentHosts: […] })` (an array of host patterns: a single string, an empty entry or a lone `*` stops the start) or `IAPL_NOINDEX=1`, or it mails the real addresses in its data), then **Send test e-mail** → "through IWSN". Turnstile (for testing site
address"** (the client's address: with the mail service replies go there). "Sending method" stays **IWSN (built-in)**; choose **Own SMTP server** and fill in its fields **only** when the client asked
for its own server — what is chosen is what is used, an incomplete SMTP server sends nothing. Save the tab once so the choice is stored. On the production domain: the block "How e-mails are sent" must say "Connected to IWSN" ("waiting for approval": while the service runs with enrolment "pending" (from its launch until Intecion switches to open enrolment), every new site waits for approval — ask Intecion to approve the host; under open enrolment it is the exception; the real domain enrols by itself at launch although the site was connected on its development address — nothing to press; "The data comes from another site" = the site is non-public (its host matches `developmentHosts`, built in `*.dev.netscale.pl`, or `IAPL_NOINDEX=1`) and holds a copy of another site's data: press "Connect again" only if the copy should send — on the production domain it means `IAPL_NOINDEX` was left set. A development address under `*.dev.netscale.pl` needs nothing; a staging or test copy on any other host must have its host in `iapl({ developmentHosts: […] })` (an array of host patterns: a single string, an empty entry or a lone `*` stops the start) or `IAPL_NOINDEX=1`, or it mails the real addresses in its data), then **Send test e-mail** → "through IWSN". Turnstile (for testing site
`1x00000000000000000000AA`, secret `1x0000000000000000000000000000000AA`; production keys from the client), analytics/pixel
IDs, IndexNow → generate key. Mail/Turnstile errors show up as a dashboard alert.
8. **Forms**: check the addresses in the Emails tab of the seeded forms.
+13
View File
@@ -672,6 +672,19 @@ PROGRAMISTA §6, items 73–75; email.md; AGENT.md §7.2) — nothing to run; re
**Send test e-mail** names the transport you expect; a form submission arrives. **The service is live at
`https://webservices.intecion.net/mail`; while the service runs with enrolment "pending" (from its launch until Intecion switches to open enrolment), every new site waits for approval — keep SMTP until it is approved, or `relay: false`.**
**→ 1.17.1, e-mail (CHANGELOG 1.17.1 point 5; email.md "Which transport a send takes"; AGENT.md §7.2) — nothing to run, one check:**
1. No schema change, no migration, no import-map change; `pnpm payload generate:types` gives a diff (the virtual field
`emailMethod`): run it and commit.
2. After the deploy open Site integrations → E-mail sending. "Sending method" shows the method the site sends through
today as selected: **IWSN (built-in)** (no SMTP server), **Own SMTP server**, or **Microsoft Graph (deprecated)**
(`GRAPH_*` on the server). Check it is the one meant, **save**, send a test e-mail: the answer names the method.
Until that save the site keeps the order of 1.17.0 and `iapl-doctor --deep` notes it (`mail-method`, info).
3. From the save on what is chosen is what is used: "Own SMTP server" with an incomplete server, or "Microsoft Graph"
without `GRAPH_*`, sends **nothing** and says so (state block, `mail-method` error) — no fallback to another method.
Tell the owner before changing the method on a live site.
4. Seeds and scripts that set up mail: write `emailMethod: 'relay' | 'smtp' | 'graph'` (or `setMailMethod(payload, …)`).
`emailTransport` written alone still works and means the old order.
**→ 1.17.1, the sign-in look (CHANGELOG 1.17.1; PROGRAMISTA §6, item 80; white-label.md → "The sign-in screens") — nothing is required:**
1. **Sites with `whiteLabel`:** after the update the login screen and the 2FA screens (code, setup) have the new
look — a dark panel with the client's logo or the site's name beside the form. No edit, no
+2 -1
View File
@@ -45,7 +45,8 @@ they will have to log in again.
### Email — nothing in env
Mail needs **no variable**. A site with no SMTP server in the panel sends through the Intecion mail service
Mail needs **no variable**. A site sends through the Intecion mail service unless an admin chose another
"Sending method" in the panel
([email.md](./email.md)); SMTP is typed in the panel. What the deploy needs for the mail service:
- **`NEXT_PUBLIC_SERVER_URL` / `serverURL` = the public address the site answers on without a redirect** (the service
+2 -1
View File
@@ -114,7 +114,8 @@ Turn off: `iapl({ doctor: false })`. Adapt: `iapl({ doctor: { tokenVar: 'MY_TOKE
| | `turnstile-env-key` | warning | (deep) the Turnstile secret key is in the panel, not in the deprecated `TURNSTILE_SECRET_KEY` environment variable |
| | `storage-names` | warning | the visitor cookie the layout sets (`<PageStats visitorCookie>`, default `ipal_vid`) is the one the config makes the cookie scanner declare (`storageNames`, stats.md) |
| | `cookie-scanner` | error / warning / info | `cookieScanner` on (with `crawl`, else info); deep: nothing waits for approval (warning) |
| mail | `mail-transport` | error / warning | (deep) an e-mail transport is in effect (not: the mail service switched off and no SMTP server); the last sends worked — failing: warning, error once it has lasted 24 hours |
| mail | `mail-method` | error / info | (deep) the chosen "Sending method" can be used — "Own SMTP server" with server, user name and password, "Microsoft Graph" with the `GRAPH_*` variables; otherwise e-mails are not sent and nothing is sent another way (error). Nobody has chosen yet: the site picks a method from what is filled in until Site integrations is saved (info) |
| | `mail-transport` | error / warning | (deep) an e-mail transport is in effect (not: the mail service switched off and no SMTP server); the last sends worked — failing: warning, error once it has lasted 24 hours |
| | `mail-non-public` | info | (deep) on the mail service: says which signal makes the site a non-public copy — its host matches a development pattern (`developmentHosts`, named in the finding) or `IAPL_NOINDEX` is set — and what to change if the site is in fact the public one |
| | `mail-relay-state` | error / warning / info | (deep) on the Intecion mail service: not disconnected and not stopped (error), not waiting for approval, not refused at enrolment, not a non-public copy of another site's database that waits for "Connect again" (`client-other-host`), the sender name not replaced (warning); not enrolled yet, and a public site whose database also holds another host's connection — its own past after a launch or a move, or a copy that forgot `IAPL_NOINDEX=1` (info) |
| | `mail-reply-address` | warning | (deep) on the mail service, "Sender address" is filled in: replies go there |
+60 -21
View File
@@ -1,19 +1,19 @@
# email
Mail works with **no setup**: a site with no SMTP server in the panel sends through the
Mail works with **no setup**: a new site sends through the
**Intecion Notifications Webservice** — **IWSN** for short, the name the admin panel uses (constant
`RELAY_SHORT_NAME`); below also "the mail service" — from
`[email protected]`, under the site's own sender name. Two more transports exist:
| Transport | When | Sender address |
|---|---|---|
| **The mail service** (`relayAdapter`, inside `mailAdapter()`) | the default — nothing filled in | `[email protected]`; replies go to the panel's "Sender address" |
| **SMTP from the panel** (`panelSmtpAdapter`) | on the client's request: its own mail server, its own sender address | the panel's "Sender address" |
| **Microsoft Graph** (`graphAdapter`) | **deprecated since 1.17.0, removed in 2.0** — sites that have the `GRAPH_*` variables | `GRAPH_SENDER` |
| **The mail service** (`relayAdapter`, inside `mailAdapter()`) | the default — "Sending method": **IWSN (built-in)** | `[email protected]`; replies go to the panel's "Sender address" |
| **SMTP from the panel** (`panelSmtpAdapter`) | "Sending method": **Own SMTP server** — on the client's request: its own mail server, its own sender address | the panel's "Sender address" |
| **Microsoft Graph** (`graphAdapter`) | "Sending method": **Microsoft Graph (deprecated)** — **deprecated since 1.17.0, removed in 2.0**; needs the `GRAPH_*` variables on the server | `GRAPH_SENDER` |
All three implement Payload's `PayloadEmailAdapter`, so `payload.sendEmail`, form mail, password reset and
account verification work whatever the transport. The project wires **one** adapter,
`buildConfig({ email: mailAdapter() })`; which transport a send takes is decided on every send.
`buildConfig({ email: mailAdapter() })`; which transport a send takes is the admin's choice in the panel.
A separate `sendEmail` helper (from `/server`) sends **always through the SMTP** from the panel.
## Wiring
@@ -33,26 +33,64 @@ The plugin does **not** set `config.email` — without `email:` Payload uses a m
## Which transport a send takes
Decided on every send from Site integrations → E-mail sending, with no stored value of its own
**The one an admin chose** in Site integrations → E-mail sending → **"Sending method"** (since 1.17.1): "IWSN
(built-in)", "Own SMTP server" or "Microsoft Graph (deprecated)". What is chosen is what is used, and it is shown:
the state block names it, the test e-mail names it, and only the fields of the chosen method are on the page (the
SMTP server, port, user name and password under "Own SMTP server"; the service's state block under "IWSN").
- **No silent switch.** Which fields happen to be filled in, or which variables the server has, no longer picks
the method. "IWSN" chosen with an SMTP server filled in sends through the service; "Own SMTP server" chosen
never contacts the service.
- **A chosen method that cannot be used fails loudly, and nothing is sent another way:**
| Chosen | What is wrong | A send | Where it shows |
|---|---|---|---|
| Own SMTP server | server, user name or password missing | `{ sent: false, code: 'not-configured' }` | state block: "Your SMTP server is chosen, but its settings are incomplete…"; status `smtp-incomplete`; doctor `mail-method` (error) |
| Microsoft Graph | the `GRAPH_*` variables are not on this server | `{ sent: false, code: 'graph-not-set-up' }` — SMTP is **not** tried | state block: "Microsoft Graph is chosen, but it is not set up on this server…"; status `graph-not-set-up`; doctor `mail-method` (error) |
| IWSN | the service cannot call the site back, the site is disconnected, waits for approval, is a held copy … | `relay-refused`, `relay-pending`, … (below) | the service's state block; doctor `mail-relay-state` |
A form submission is stored whatever happens to its e-mail, as before.
- One exception that was always there: with **Microsoft Graph** chosen, a file too large for Graph goes over the
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`).
**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
(`resolveMailTransport(settings, { graphEnv, relay })` returns `'graph' | 'smtp' | 'relay' | 'none'`, type `MailTransport`):
1. "Sending method" is Microsoft Graph **and** the four `GRAPH_*` variables are set → **Graph**, as before (deprecated).
1. `emailTransport` is `graph` **and** the four `GRAPH_*` variables are set → **Graph** (deprecated).
2. The panel has an SMTP server (server, user name and password) → **SMTP**.
3. The four `GRAPH_*` variables are set → **Graph** (deprecated), until they are removed.
3. The four `GRAPH_*` variables are set → **Graph** (deprecated).
4. Otherwise → **the mail service**, unless it is switched off (`mail: { relay: false }`).
5. Otherwise nothing is configured: the send reports `{ sent: false, code: 'not-configured' }`, as before 1.17.0.
5. Otherwise nothing is configured: the send reports `{ sent: false, code: 'not-configured' }`.
**Half an SMTP set-up** (a server and a user name without a password, say) is not an SMTP server: until 1.16 such
a site refused to send; now its mail goes through the mail service. The server log says so once and the state
block shows "The SMTP settings below are incomplete".
| The site before the upgrade | "Sending method" shows | Mail |
|---|---|---|
| 1.17.0, no SMTP server (sends through the service) | IWSN (built-in) | as before |
| SMTP server filled in (1.16.x or 1.17.0) | Own SMTP server | as before |
| `GRAPH_*` on the server (with "Microsoft Graph" stored, or with no SMTP server) | Microsoft Graph (deprecated) | as before, with the deprecation notice |
| half an SMTP set-up, no `GRAPH_*` | IWSN (built-in), with the hint "The SMTP settings below are incomplete" | through the service, as in 1.17.0 |
| a new site | IWSN (built-in) | through the service |
**The first save of Site integrations stores what the form shows** (the form always sends the field), and from
then on the method is fixed. The state block says "Nobody has chosen the sending method yet, so the site picked
this one. Save this page to keep it." until then, and the doctor's deep run notes it (`mail-method`, info). A script
of before 1.17.1 that writes `emailTransport` alone still means what it meant: it puts the site back on the order
above (write `emailMethod` to choose).
- **A site with SMTP filled in never contacts the mail service.** Nothing changes for it.
- **SMTP on the client's request:** an admin fills in "Own SMTP server", user name and password; from the next send
the site uses the client's server and the client's own sender address. Emptying the server returns the site to
the mail service.
- There is **no fallback** from a failing SMTP server to the mail service: a client who asked for its own server
gets no mail from another address.
- "Sending method" keeps its two stored values (`smtp`, shown as "Automatic", and `graph`); no field was added.
## The mail service
@@ -466,8 +504,9 @@ expect(relay.outbox[0]).toMatchObject({ kind: 'system', to: ['[email protected]'] })
## SMTP — on the client's request
The panel's SMTP fields (`smtpHost`, `smtpPort` (default 587), `smtpUser`, `smtpPassword`, `smtpFromAddress`,
`smtpFromName`) and `emailTransport` live in Site integrations (E-mail sending tab). Filling in server, user name
and password switches the site to the client's server.
`smtpFromName`) live in Site integrations (E-mail sending tab); server, port, user name and password are shown
while "Sending method" is "Own SMTP server". Choose that method, fill them in and save: the site sends through the
client's server (a site nobody has chosen a method for yet does so as soon as the three are filled in).
- **The password is write-only and stays with its server**: the panel shows "A value is set"; changing the
server, port or user name asks for the password again ([security.md](./security.md) "Stored secrets").
@@ -587,8 +626,8 @@ To the mail service (when the owner says so):
1. Upgrade; check that `serverURL` is the site's public address.
2. Tell Intecion the host: while the service runs with enrolment "pending" (from its launch until Intecion switches to open enrolment), every new site waits for approval; the panel says so. Under open enrolment the site is active as soon as it enrols.
3. Remove the four `GRAPH_*` variables in Coolify and redeploy. If "Sending method" says Microsoft Graph, set it
to "Automatic".
3. Site integrations → E-mail sending → "Sending method": choose **IWSN (built-in)** and save. Then remove the four
`GRAPH_*` variables in Coolify and redeploy.
4. Site integrations → E-mail sending → send a test e-mail: the answer says "through IWSN".
5. Check "Sender name" and "Sender address" (now the reply address), and tell the client that mail now comes from
`[email protected]` instead of the present mailbox (allow-lists, filters).
+2 -2
View File
@@ -14,7 +14,7 @@ Currently always added by the plugin. Tabs (unnamed — flat data, e.g. `ga4Meas
|---|---|
| Analytics | `ga4MeasurementId`, `gtmContainerId`, `metaPixelId`, `clarityProjectId`, `linkedInPartnerId`, `tiktokPixelId` |
| Spam protection | `turnstileSiteKey`, `turnstileSecretKey`, hidden `turnstileStatus` + banner |
| E-mail sending | the state block "How e-mails are sent" (part of the tab's status banner — nothing stored; absent with `mail: { relay: false }`), `emailTransport` (`smtp` = "Automatic" / `graph` = deprecated), `smtpHost`, `smtpPort`, `smtpUser`, `smtpPassword`, `smtpFromAddress`, `smtpFromName`, test button, hidden `emailStatus` + banner |
| E-mail sending | the state block "How e-mails are sent" (part of the tab's status banner — nothing stored; absent with `mail: { relay: false }`), "Sending method" `emailMethod` (virtual: `relay` = IWSN / `smtp` / `graph` = deprecated; the choice is kept in `payload-kv`), `emailTransport` (hidden; the stored field of 1.6 – 1.17.0), `smtpHost`, `smtpPort`, `smtpUser`, `smtpPassword`, `smtpFromAddress`, `smtpFromName`, test button, hidden `emailStatus` + banner |
| IndexNow | `indexNowKey` (generated on first save) |
| More | fields from the `integrationsFields` option — only when given |
@@ -37,7 +37,7 @@ The state block above it reads `GET /api/iapl/mail-relay/status` and acts throug
or at most every 10 min while an error lasts; it never throws. The same change already being written (many sends
failing at once) is written once; while every transaction place of a Postgres pool is taken
([deployment.md](./deployment.md) §4.3a) the write goes on in the background instead of holding the caller.
- **Changing keys in the admin panel** (Turnstile, `emailTransport` / `smtp*`) clears that integration's old status.
- **Changing keys in the admin panel** (Turnstile, the sending method / `smtp*`) clears that integration's old status.
- **`emailStatus.code`** of a send through the Intecion mail service is one of the `relay-…` codes (`relay-pending`,
`relay-quota`, `relay-unreachable`, …), each with a text in the editor's language — the list and what to do:
[email.md](./email.md) "Status codes". The token of the mail service is **not** in this global: it lives in
+3 -3
View File
@@ -1063,9 +1063,9 @@ not enough on its own: an admin session could point `smtpHost` / `smtpPort` at a
"Send test e-mail", and read the password off the connection. So a save **through access control** (the panel,
REST, GraphQL) that changes `smtpHost`, `smtpPort` or `smtpUser` while a password is stored must send the
password again — or remove it (`'[[clear]]'`, "Remove the stored value") for a server without one. **Whatever
the transport says:** "Microsoft Graph" in the panel does not mean Graph sends — the mail adapter falls back to
SMTP when Graph is not configured, and for attachments Graph cannot take. A change of `emailTransport` alone
asks for nothing. Values are compared exactly (`587` and `'587'` are the same; another letter case or a space
the sending method says:** with "Microsoft Graph" chosen the SMTP server is still used for attachments Graph cannot
take (and, on a site nobody has chosen a method for, when Graph is not configured). A change of the sending method
alone asks for nothing. Values are compared exactly (`587` and `'587'` are the same; another letter case or a space
is a change), and a value never saved — or a `NULL` in a SQL row — counts as the field's default, so saving
the form unchanged asks for nothing. Server code — a seed, a script with the Local API and access control off
— is not asked. `iapl({ secrets: { reenterOnChange: false } })` = the stored password follows the new