Mail relay: docs, agent guide, skills, changelog draft; test against the real service code; starter offers the mail service

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-25 20:53:38 +01:00
co-authored by Claude Fable 5.2
parent 533f571d4d
commit dd3792cbc7
25 changed files with 991 additions and 167 deletions
+71 -3
View File
@@ -9,15 +9,47 @@ 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.0 — the plugin is called IAPL (draft)
## 1.17.0 — the plugin is called IAPL; mail works with no setup (draft)
> **Read before upgrading.** Nothing has to change in a project. The plugin's name is now **IAPL** (Intecion
> Advanced Payload Library); it was ipal-kit. **The package is still `@intecion/ipal-kit`**, and every name a
> project uses keeps working. No option, schema, migration or import-map change. This release also carries the
> project uses keeps working. The rename changes no option, schema, migration or import map. This release also carries the
> security follow-ups listed under 1.16.8 below (prepared, not released on their own).
>
> **E-mail — read which of three cases the site is.** A site with **no SMTP server in Site integrations and no
> `GRAPH_*` variables** (its mail failed with "not configured" until now) starts sending through the **Intecion
> Notifications Webservice** after the upgrade: on its next e-mail it contacts `webservices.intecion.net` with its
> host and the plugin version, receives its own token through a new public route, and sends from
> `[email protected]` under the panel's "Sender name". **A site with SMTP filled in is not
> affected and contacts nothing. A site on Microsoft Graph keeps working and prints one deprecation warning at
> start.** Each new behaviour has its opt-out (table below). No schema change, no migration; one import-map entry.
> **The service must be live for the first case: until Intecion announces it, such a site reports
> `relay-unreachable` and sends nothing, as it sent nothing before.**
### Requires project changes
- **Nothing.** Recommended after the update: `pnpm exec iapl-skills` (or the project's `ipal:skills` script) and commit —
- **Every site: `pnpm payload generate:importmap`, commit.** The e-mail tab of Site integrations has a new block
("How e-mails are sent", component `@intecion/ipal-kit/admin#MailRelayStatus`); with a stale import map the block is
blank. Nothing else changes in the panel's data: no field was added, "Sending method" keeps its two stored values.
- **What changes for an existing site on upgrade — e-mail:**
| Site today | After the upgrade | Opt-out |
|---|---|---|
| SMTP filled in (server, user name, password) | Nothing. No call to Intecion | — |
| `GRAPH_*` set and "Microsoft Graph" chosen | Mail as before. One deprecation warning in the start log, one doctor warning (`mail-graph-deprecated`) | `mail: { graphDeprecationWarning: false }` (the log line) |
| `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 |
| "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 | — |
For a site that will send through the service: `serverURL` must be the public address the site answers on **without
a redirect**; "Sender address" should be filled in (replies go there — the service's address has no mailbox);
`trailingSlash: true` or a `routes.api` other than `/api` needs Intecion to set the site's confirm address first;
the client's processing agreement should name the service (recipients and message bodies pass through it).
Steps and checks: `iapl-upgrade` "→ 1.17.0, e-mail", [email.md](./email.md).
- **Microsoft Graph is deprecated and will be removed in 2.0** (with Payload 4). It works unchanged through 1.x.
To move a site: [email.md](./email.md) "Moving off Microsoft Graph" — when the owner says so, not in passing.
- **Otherwise nothing.** Recommended after the update: `pnpm exec iapl-skills` (or the project's `ipal:skills` script) and commit —
the skills are named `iapl-*` now; the 16 old `ipal-*` folders are removed by name, a project's own `ipal-…` skill
stays, and the pointer block in `AGENTS.md` is rewritten in place.
- **A log filter or alert on `[ipal]`, or a script that reads the doctor's output:** the log prefix is `[iapl]`; the
@@ -49,6 +81,36 @@ once there are more than 20.
keep their doctor rule ids, so settings in a project's doctor file still match.
### Added
- **The Intecion Notifications Webservice as the default e-mail transport** ([email.md](./email.md), AGENT.md §7.2).
`mailAdapter()` now picks per send: Graph when the panel says so and `GRAPH_*` is set → SMTP when the panel has a
server → Graph when `GRAPH_*` is set → the mail service → not configured (`resolveMailTransport`). The site holds no
mail key: it enrols by a call-back to its own domain and keeps its token in `payload-kv` (key `iapl:mail-relay` —
no field, no column; not readable over REST or GraphQL, an admin included; proven by a test). The token is bound to
the site's server addresses, 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,
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 })`.
- **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
"Own SMTP server"; the test e-mail names the transport it used. New status codes `relay-*` with texts in English
and Polish. With `relay: false` the tab is worded as in 1.16.
- **Doctor:** `mail-transport`, `mail-relay-state`, `mail-reply-address`, `mail-graph-deprecated`, `mail-relay-route`;
the status endpoint reports `mail` (states and codes only).
- **Building blocks (root entry):** `relayAdapter`, `enrolRelay`, `getRelayStatus`, `rotateRelayToken`,
`disconnectRelay`, `setRelayToken`, `sendThroughRelay`, `relayRequest`, `buildRelayMessage`, `bareAddress`,
`bareAddresses`, `cleanSubject`, `relayConfirmEndpoint`, `relayPanelEndpoints`, `mailPanelState`,
`resolveRelayOptions`, `relayHost`, `isPublicHost`, `relaySenderName`, `relayAttachmentLimit`, `relayStatusFor`,
`withMailKind`, `runWithMailKind`, `mailKindOf`, `expectMailTo`, `buildFormMailKindHook`, `createFakeRelay` (the
service in memory, for tests), the constants `RELAY_*`, `MAIL_KINDS`, `MAIL_KIND`, `GRAPH_DEPRECATION_NOTICE`, and
their types; `MailRelayStatus` from `/admin`.
- The wire contract of the service (version 1.5.0) is copied in the repository (`contracts/mail-relay/`) with a
checksum test; every example of it runs against the plugin's fake service and against the plugin's client.
- **`iapl-doctor` rule `legacy-names`** (info): lists the old names a project still uses, each with the new one.
Information, not a defect. A warning only for `iapl-doctor.json` and `ipal-doctor.json` side by side, or one variable
set as `IAPL_…` and `IPAL_…` with different values (the `IAPL_` one is read).
@@ -61,6 +123,12 @@ once there are more than 20.
Not a switch for a live site: it would start visitors' histories and the running 2FA counts again.
- `EnvRule.aliases` for `assertEnv`: older names of a variable, read when the main one is missing.
### Deprecated
- **Microsoft Graph as an e-mail transport** — `graphAdapter`, `GraphAdapterArgs`, `mailAdapter({ graph })`,
`iaplEnvRules({ emailGraph })` and the four `GRAPH_*` variables. Nothing new is built on it; it gets fixes only and
is removed in 2.0. A site on it prints one warning per start (silence: `mail: { graphDeprecationWarning: false }`);
the starter and `iapl-setup` no longer offer it.
## 1.16.8 — security follow-ups to 1.16.7
> **Read before upgrading.** No option, schema, migration or import-map change. Three points:
+1 -1
View File
@@ -32,7 +32,7 @@ API details — one file per module:
| New site in one command (`iapl create`, `@intecion/ipal-kit/starter`) | [project-starter.md](./project-starter.md) |
| Deployment, production variables, health check | [deployment.md](./deployment.md) |
| Seeds: create-only, dry run, backup, production update guard | [seeding.md](./seeding.md) |
| Email SMTP / Graph | [email.md](./email.md) |
| E-mail: the mail service (default), SMTP, Graph (deprecated) | [email.md](./email.md) |
| Env validation | [env.md](./env.md) |
| Forms, useForm, honeypot | [forms.md](./forms.md) |
| GA4 + Meta Pixel through GTM (form events) | [gtm-meta-pixel.md](./gtm-meta-pixel.md) |
+115 -5
View File
@@ -47,7 +47,7 @@ use the name in the middle column. `pnpm exec iapl-doctor` lists what is still o
| Name | Why |
|---|---|
| package `@intecion/ipal-kit` and every import path (`@intecion/ipal-kit/client`, `…/tokens.css`), import-map paths `@intecion/ipal-kit/admin#…`, `node_modules/@intecion/ipal-kit/docs/…` | the package name changes in 2.0 |
| routes `/api/ipal/…` | proxies, cached pages and the crawler call them |
| routes `/api/ipal/…` | proxies, cached pages and the crawler call them (the mail service's four routes, new in 1.17.0, are `/api/iapl/mail-relay/…`) |
| CSS tokens `--ipal-*`, hooks `data-ipal="…"` | projects' own CSS uses them |
| `config.custom.ipal`, `custom.ipalAccounts`, `req.context` flags (`ipalSeed`, `ipalSkipIndexNow`, `ipalSkipAutoFill`, …), `ipalTotpView` server props, translation namespace `ipal` | projects' hooks and overrides read them |
| header `X-Ipal-Cookie-Crawler` | WAF rules |
@@ -121,7 +121,7 @@ the ready-to-send list is in **iapl-setup** stage 0 (iapl-site phase 0 uses the
| Languages | which locales, the default locale, URL structure (`/pl/…` for every language, or the default without a prefix) |
| Styling | a design system / `DESIGN.md` or plain Tailwind tokens, brand colours, fonts, light/dark theme |
| Content | the pages, the collections (blog, case studies, products…), archive pages |
| Forms | which forms, who receives them, e-mail provider (SMTP from the panel or Microsoft Graph) |
| Forms | which forms, who receives them; e-mail: the built-in mail service by default — ask only whether the client wants its **own SMTP server and sender address** (never offer Microsoft Graph: deprecated) |
| Analytics and consent | GA4 / GTM / pixels, Consent Mode basic or advanced, cookie banner mode, cookie scan |
| SEO / GEO | market and local business data, AI crawler policy (llms.txt, Markdown, MCP, AI bots) |
| Data and media | database (Postgres or MongoDB) and its names (`<domain without dots>_prod` / `_dev` — derive, then confirm), media storage (R2 or local disk) |
@@ -1166,7 +1166,7 @@ project → **plugin gap**, not a copy.
| Cookie list filled from the panel (scan, then one approval adds every cookie to the list, the policy table and the detailed window) | `iapl({ cookieScanner: true })` + `pnpm generate:importmap` + migration; the editor approves on `/admin/cookie-approval`; project cookies: `cookieScanner.declarations` / `integrations`; per-entry review: `approval: false` — do not type the list by hand or build your own scanner or approval page | cookie-scanner.md |
| Pre-consent check in a browser (button in the panel, violations, dashboard + e-mail warning) | `cookieScanner: { crawl: true }` + env `IAPL_COOKIE_SCAN_URL` / `IAPL_COOKIE_SCAN_TOKEN` (`iaplEnvRules({ cookieCrawl: true })`) + the site's `host=token` in the shared service's `IAPL_CRAWLER_SITES`; never Playwright/Chromium in the site | cookie-scanner.md → Browser crawl |
| GA4, GTM, Pixel, Clarity, LinkedIn, TikTok | IDs in the panel — `SiteProviders` loads `Analytics` (`analytics={{ defer: true }}`; `consentMode: 'basic'` = no Google request before consent) | analytics.md |
| Mail | `email: mailAdapter()`, `sendEmail` | email.md |
| Mail | `email: mailAdapter()` + `serverURL` — mail works with no other setup, through the Intecion mail service; SMTP in the panel only when the client asks; your own mail: `payload.sendEmail` (`withMailKind` when it is account mail); never a second transport in the project. §7.2 | email.md |
| Env validation, health | `assertEnv(iaplEnvRules({…}))` (`/env`), `healthRoute` | env.md |
| 2FA, white-label, headers | `twoFactor: { issuer, plugin: payloadTotp }`, `whiteLabel`, `buildSecurityHeaders` | security.md, white-label.md |
| Panel link preview + noindex (site name, description, preview image, technology support credit) | on by default (`adminMeta`, `agency`) — do not hand-write `admin.meta` for it; override single keys in `admin.meta` or `adminMeta: { … }` | white-label.md |
@@ -1241,6 +1241,116 @@ 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 |
| 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` |
| Microsoft Graph as transport: deprecated, one warning per start, removed in 2.0 | `mail: { graphDeprecationWarning: false }` (the warning only) | move off it: email.md "Moving off Microsoft Graph" |
### 7.2 E-mail — the mail service (default), SMTP (on request), Graph (deprecated)
**What you wire — three lines, every site:**
```ts
// src/payload.config.ts
import { iapl, mailAdapter } from '@intecion/ipal-kit'
export default buildConfig({
serverURL: process.env.NEXT_PUBLIC_SERVER_URL, // the public https address the site answers on, without a redirect
email: mailAdapter(),
plugins: [iapl({ /* … */ })],
})
```
Then `pnpm generate:importmap` (the e-mail tab has a new component, `@intecion/ipal-kit/admin#MailRelayStatus`).
No env variable, no key, no field to fill in. **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.
**What the site needs for the mail service** — check each one:
1. `serverURL` is the production host itself (`https://example.com`, not a host that redirects to `www`).
2. `POST https://<host>/api/iapl/mail-relay/confirm` is reachable from the internet with no redirect, no basic
auth, no firewall rule. `trailingSlash: true` in `next.config` or another `routes.api` break it — the fix is
Intecion setting the site's confirm address, not moving the route (email.md "When the site cannot be confirmed").
3. The server may call `https://webservices.intecion.net`.
4. Site integrations → E-mail sending: "Sender name" (else the site name is used) and **"Sender address"** — with
the mail service that is where replies go; the service's own address has no mailbox.
5. Intecion has listed the host; otherwise the site enrols and waits for approval (`relay-pending`).
**Verify:** Site integrations → E-mail sending → the block "How e-mails are sent" says "Connected to the built-in
mail service"; **Send test e-mail** answers "through the built-in mail service, as <name>"; the mail arrives from
`[email protected]` with the client's name and `Reply-To` the client's address; `iapl-doctor
--url` 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
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:
```ts
import { runWithMailKind, withMailKind } from '@intecion/ipal-kit'
await payload.sendEmail(withMailKind({ to: user.email, subject, html }, 'account')) // to an account holder only
await runWithMailKind('account', () => inviteUsers(payload, list))
```
Kinds (`MailKind`, `MAIL_KINDS`, key `MAIL_KIND`, reader `mailKindOf`): `form-notification`, `form-confirmation`
(both set by the plugin on every form e-mail — `buildFormMailKindHook`), `account` (Payload's "forgot password" and
"verify your e-mail": set by the plugin through `expectMailTo`), `test`, `security-alert`, `system` (the default).
A wrong kind gives a visitor more room than the service means to give: `account` only for mail to an account
holder, `form-confirmation` for an address a visitor typed.
**Options** — `iapl({ mail: { relay, graphDeprecationWarning } })` (`MailOptions`, `RelayOptions`; `mailAdapter({ relay })`
overrides per adapter; `resolveRelayOptions` reads what is in effect):
| Key | Default | Meaning |
|---|---|---|
| `relay: false` | on | no mail service: no outbound call, no routes, no state block |
| `url` | `RELAY_BASE_URL` | a relay of your own (same contract) |
| `host` | host of `serverURL` (`relayHost`, `isPublicHost`) | the public host the service calls back |
| `enrol` | `'auto'` | `'manual'` (only "Connect again" / `enrolRelay`), `false` (token from `token` / `setRelayToken`) |
| `token` | — | a token from elsewhere; nothing is stored, the site does not enrol |
| `senderName` | panel → site name (`relaySenderName`) | fixed name or function |
| `kind` | — | kind of a message nobody marked |
| `accountMail` | `{ perAddress: 5, perVisitor: 10, windowMinutes: 60 }` | the site's own limit on account mail; `false` = none |
| `confirmRateLimit` | `{ max: 10, windowMs: 60000 }` | the public confirm route, per address |
| `timeoutMs`, `retryBackoffMs`, `fetchImpl` | 30 s, 1 s, `fetch` | one attempt; wait between attempts; tests |
| `graphDeprecationWarning` | `true` | `false` = no start warning on a Graph site (`GRAPH_DEPRECATION_NOTICE`) |
**Routes the plugin adds** (gone with `relay: false`): `POST /api/iapl/mail-relay/confirm` — public, `404` unless
the site itself just started an enrolment, rate-limited; allow it in any WAF or proxy rule. Admin only:
`GET /api/iapl/mail-relay/status` (`?refresh=1`), `POST …/connect` (optionally `{ token }`), `POST …/disconnect`.
**Failures** are recorded in `emailStatus` with a code (`RELAY_STATUS_CODES`, `RelayStatusCode`, `relayStatusFor`):
`relay-pending`, `relay-suspended`, `relay-refused`, `relay-disconnected`, `relay-quota`, `relay-too-large`,
`relay-attachment-refused`, `relay-recipient-suppressed`, `relay-unreachable`, `relay-not-confirmed`, `relay-error`
(and the warning `relay-name-replaced`) — what each means and what to do: `iapl-debug`, "E-mail". A send returns
`RelaySendResult`; `confirmed: false` means the message **may** have been sent — do not send it again under
another content; the same message sent again reuses its key and cannot double.
**Limits** (the service's; per site): 30 messages an hour, 200 a day, 10 recipients a message, 10 MB of files —
read from the service (`mailAttachmentLimit`, `relayAttachmentLimit`), never typed into a project. A site that
needs more: Intecion raises the limits, or SMTP.
**Building blocks** (root entry; all optional — the three lines above are enough):
| Need | Use |
|---|---|
| The transport alone, no SMTP / Graph | `email: relayAdapter()` (`RelayAdapterArgs`) |
| Enrol from a deploy script; state; rotate; disconnect; a token issued by hand | `enrolRelay` (`EnrolResult`), `getRelayStatus` (`RelayStatus`), `rotateRelayToken`, `disconnectRelay`, `setRelayToken` |
| Your own state block or panel route | `mailPanelState` (`MailPanelState`), `relayPanelEndpoints`, `relayConfirmEndpoint`; the plugin's component is `MailRelayStatus` (`/admin`) |
| One message with the retry rule; one HTTP call | `sendThroughRelay` (`RelaySendContext`, `RelaySendResult`), `relayRequest` (`RelayCall`, `RelayAnswer`, `RelayRefusal`) |
| The request the service takes | `buildRelayMessage` (`BuildRelayMessageArgs`, `BuiltRelayMessage`, `RelaySendRequest`), `bareAddress`, `bareAddresses`, `cleanSubject` |
| Constants | `RELAY_BASE_URL`, `RELAY_CONFIRM_PATH`, `RELAY_CONTRACT_VERSION`, `RELAY_DEFAULTS`, `RELAY_KV_KEY`, `RELAY_PRODUCT`, `RELAY_SENDER_ADDRESS`, `RELAY_SERVICE_NAME` |
| Tests without the service | `createFakeRelay` (`FakeRelay`, `FakeRelayOptions`, `FakeRelayMail`, `FakeRelayLimits`): `mailAdapter({ relay: { url: fake.url, fetchImpl: fake.fetch } })`, then assert on `fake.outbox` |
**Never:** read or print the token (`payload.kv`, key `iapl:mail-relay`); add a field or env variable for it; call
the service from a client component; retry a failed send in a loop of your own; mark form mail as `account`.
---
@@ -1407,7 +1517,7 @@ Anything that needs a developer → move it to the panel.
| Cookie consent, banner | [consent.md](../consent.md) |
| Cookie scanner (review list, Open Cookie Database) | [cookie-scanner.md](../cookie-scanner.md) |
| Routing, archives, redirects, Markdown, search | [content.md](../content.md) |
| Email SMTP / Graph | [email.md](../email.md) |
| E-mail: the mail service (default), SMTP, Graph (deprecated) | [email.md](../email.md) |
| Env validation | [env.md](../env.md) |
| Forms, useForm, honeypot | [forms.md](../forms.md) |
| Hooks | [hooks.md](../hooks.md) |
@@ -1449,7 +1559,7 @@ file points to them.
# AGENTS.md
**Project:** <client> · <domain> · market <PL/AU/US> · industry <…>
**Languages:** <pl, en, de> · **Media:** <R2 / local> · **Email:** <SMTP / Graph>
**Languages:** <pl, en, de> · **Media:** <R2 / local> · **Email:** <mail service / own SMTP>
## Rules
Before your first change, read all of:
+18 -1
View File
@@ -97,7 +97,24 @@ 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 transport / empty Emails tab | email.md; Send test in the panel |
| 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 |
| 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` |
| `relay-pending` / "waiting for approval" | the host is not on Intecion's list | Intecion approves it on the service; nothing to change on the site; the same token then works |
| `relay-suspended` | Intecion stopped the site (abuse, a flood from a form) | contact Intecion; fill in SMTP meanwhile |
| `relay-disconnected` | an admin pressed "Disconnect" | "Connect again", or SMTP |
| `relay-quota` | the site's hour or day is used up (30 / 200 by default), more than 10 recipients, more than 10 confirmations to one address a day, too many new addresses, or the site's own limit on account mail (`mail.relay.accountMail`) | the server log names the limit; look for a form being abused (Turnstile on? rate limit?); a site that really sends more: Intecion raises the limits, or SMTP |
| `relay-too-large` / `relay-attachment-refused` | files over the service's limit (10 MB a message); a program or script as attachment | lower the File field's maximum (`iapl-form`); other file types; SMTP for larger files |
| `relay-recipient-suppressed` | one recipient's mailbox bounced or complained before (for any site); nothing was sent to anybody | correct the address in the form's Emails tab; ask Intecion to clear the address |
| `relay-unreachable` | the service or its mail back end failed, or the server cannot reach `webservices.intecion.net` | `curl -s https://webservices.intecion.net/mail/health` from the server → `{"ok":true}`; if it persists: SMTP, and tell Intecion |
| `relay-not-confirmed` / "may have been sent" | no answer from the service (time-out, connection lost) | check the recipient's mailbox **before** sending again; the same message sent again cannot double |
| `relay-error` | the service refused the request as wrong (a bug), or the message has no valid recipient or no body | server log line `[iapl] mail service: …` → `iapl-plugin-gap` |
| the mail arrives under the site's host instead of the client's name | the service did not accept "Sender name" (an address, a bank or provider name, mixed scripts, over 64 characters) — the state block says which name was used | another name; an honest name that is still replaced → Intecion |
| replies to the site's mail are lost | "Sender address" is empty: the service's own address has no mailbox | fill it in (doctor: `mail-reply-address`) |
| the site enrols again and again (`reverify` in the log) | requests leave from many changing addresses (serverless, a pool of egress addresses) | Intecion raises the site's limit of server addresses, or SMTP |
| start log: "Microsoft Graph as the e-mail transport is deprecated" | `GRAPH_*` is set | email.md "Moving off Microsoft Graph"; silence only: `mail: { graphDeprecationWarning: false }` |
| the e-mail tab shows a blank where "How e-mails are sent" should be | stale import map | `pnpm payload generate:importmap`, commit, redeploy |
| old email sender | mail client cache | check the raw headers |
| form: `unknown_fields` | field outside the definition (honeypot not removed) | `iapl-form` → actions.ts |
| an account logs in to `/admin` and sees "Unauthorized" (its API calls still work) | `accounts.panelRole`: the panel opens for `editor` and above; the account has only `user`, or no role | give it `editor` (an admin edits the account), or `accounts: { panelRole: 'user' }`; nobody can get in: a script with the Local API sets `roles: ['admin']`, or `accounts: { panelRole: false }` + redeploy |
+4
View File
@@ -21,6 +21,10 @@ Full reference: `node_modules/@intecion/ipal-kit/docs/doctor.md`.
```
2. Show the user the **full output**. Every finding names its rule, the file, a fix and a doc.
3. Fix every `error`. A `warning` is drift — fix it or tell the user why not. `info` is a note.
E-mail findings (`--deep`): `mail-transport` (nothing set up, or sending fails), `mail-relay-state` (the site's state
with the Intecion mail service: waiting for approval, stopped, refused, disconnected, a replaced sender name),
`mail-reply-address`, `mail-graph-deprecated`, `mail-relay-route` (trailing slashes, another API route, a redirect or a
block in front of `/api/iapl/mail-relay/confirm`) — fixes: `iapl-debug` "Consent / analytics / forms / email".
4. A deliberate exception (the owner's decision) goes into `iapl-doctor.json` **with a reason** — the same reason as in
AGENTS.md "Project decisions". Never silence a rule just to make the run pass:
```json
+2
View File
@@ -109,6 +109,8 @@ Never build this by hand (your own `<input type="file">`, upload route or upload
the visitor that the problem is the **file**, why, and what to do (a smaller file, another format; on an
optional field also "send the form without the file"). They show at the File field; what the visitor typed stays.
6. Mail size: **Site integrations → E-mail sending → Test e-mail** with **Attach a 10 MB test file** must arrive.
The mail service (the default transport): 10 MB for all files of one message unless Intecion set another number
for the site — the form's limit follows what the service reports by itself, and programs and scripts are refused.
SMTP: the provider's limit decides (a 10 MB server limit carries only ~7 MB of file — lower the field's
maximum). Microsoft Graph: files of 3 MB and more need the `Mail.ReadWrite` permission on the agency app
(email.md "Attachments"); without it they go over SMTP when the panel has SMTP settings, else the form's limit
+19 -8
View File
@@ -43,7 +43,8 @@ Before I set up the site I need your decisions on:
1. Languages: which ones, which is the default, URLs — every language with a prefix (/pl/…, /en/…) or the default without one?
2. Styling: a design system / DESIGN.md, or Tailwind tokens from scratch? Brand colours, fonts, light/dark theme?
3. Pages and content: which pages? Lists with their own URLs (blog, case studies, products) and their archive pages?
4. Forms: which forms, who receives the submissions, e-mail via SMTP (panel) or Microsoft Graph?
4. Forms: which forms, who receives the submissions? E-mail works through the built-in Intecion mail service with no
setup — does the client want its **own SMTP server and sender address** instead? (Never offer Microsoft Graph: deprecated.)
5. Analytics and consent: GA4 / GTM / Meta / other pixels? Consent Mode basic or advanced? Cookie dialog
inline / modal / detailed? Cookie scan of the finished site?
6. SEO/GEO: market, local business (address, opening hours)? AI access (llms.txt, Markdown, MCP, AI bots) — on?
@@ -199,8 +200,9 @@ export default buildConfig({
`.env.example` (no values, in the repo): `DATABASE_URI`, `PAYLOAD_SECRET`, `NEXT_PUBLIC_SERVER_URL`, `R2_BUCKET`,
`R2_ENDPOINT`, `R2_ACCESS_KEY_ID`, `R2_SECRET_ACCESS_KEY`, `R2_PUBLIC_URL` (empty = media through the app — the default), `IAPL_IP_HEADER` (`cf-connecting-ip`
behind Cloudflare, `x-forwarded-for` behind a plain proxy), `IAPL_NOINDEX` (empty; `1` on staging only), `INDEXNOW_KEY`,
`NEXT_PUBLIC_TURNSTILE_SITE_KEY`, `TURNSTILE_SECRET_KEY` (deprecated fallback — production keys go into the panel), with Graph `GRAPH_TENANT_ID`,
`GRAPH_CLIENT_ID`, `GRAPH_CLIENT_SECRET`, `GRAPH_SENDER`. Local `.env` with `PAYLOAD_SECRET` ≥ 32 characters (in production `iaplEnvRules` refuses a shorter one; `secretMinLength` changes it).
`NEXT_PUBLIC_TURNSTILE_SITE_KEY`, `TURNSTILE_SECRET_KEY` (deprecated fallback — production keys go into the panel). **No variable for mail**: the
mail service needs none, SMTP is typed in the panel, and `GRAPH_TENANT_ID` / `GRAPH_CLIENT_ID` / `GRAPH_CLIENT_SECRET` / `GRAPH_SENDER` (Microsoft Graph, deprecated, removed in 2.0)
are never added to a new site. Local `.env` with `PAYLOAD_SECRET` ≥ 32 characters (in production `iaplEnvRules` refuses a shorter one; `secretMinLength` changes it).
One language: one entry in `locales`, no `[locale]` folder (i18n.md).
**Check.** `pnpm payload generate:importmap` (whiteLabel adds admin components) and `pnpm generate:types` without
@@ -295,7 +297,10 @@ the panel shows Site settings, Site integrations, Cookies, Form messages, the Fo
preview image (`/api/ipal/admin-og`) from Site settings; `agency` names who supports the technology (default
Intecion.com). Turn off: `adminMeta: false`, `agency: false`; your own `admin.meta` keys win. Check:
`curl -s localhost:3000/admin/login | grep -E 'og:|robots'` → `noindex, nofollow`, `og:site_name` = Site settings name.
- Mail: any Payload adapter instead of `mailAdapter()`; `mailAdapter({ fallbackFromAddress, smtp, graph })`.
- Mail: the Intecion mail service is the default transport (AGENT.md §7.2, email.md). Off: `iapl({ mail: { relay: false } })`
(SMTP only, no outbound call, no `/api/iapl/mail-relay/*` routes). Override: `mail: { relay: { host, enrol, token, senderName,
kind, accountMail, url } }`, `mailAdapter({ fallbackFromAddress, relay, smtp })`; the transport alone: `relayAdapter()`; any
Payload adapter instead of `mailAdapter()`. `serverURL` must be the public address — the service calls the site back there.
- R2: other storage-s3 options (prefix, clientUploads) → call `s3Storage` yourself instead of `buildR2Storage`.
- `forms: { adminGroup, fields, formOverrides, formSubmissionOverrides, beforeEmail, emailLayout }` (forms.md).
- `adminRoute: '/its'` — requires moving `app/(payload)/admin` → `its`, a proxy matcher with `its` (stage 6)
@@ -572,8 +577,10 @@ every language, consent checkbox). Cookies: skill **iapl-consent-check** — `co
Cookies → Cookie list; on the cookie policy page a block with `<CookieTable>` (`/rsc`, data from `getCookieTable`);
the same list appears in the `settings="detailed"` dialog (labels: Cookies → Settings window → Cookie list headings, every language).
**Check.** Panel → Forms: the seeded form; a submission on `/pl` → an entry in Form Submissions + 2 emails (SMTP:
Site integrations → E-mail sending → Send test); with Turnstile test keys the widget is visible, without a token the submission is rejected;
**Check.** Panel → Forms: the seeded form; a submission on `/pl` → an entry in Form Submissions + 2 emails. Mail on a
development machine: the mail service does not enrol a site on `localhost` (the state block says so; nothing leaves the
machine) — fill in a local SMTP catcher (Mailpit: server `127.0.0.1`, port `1025`, any user name and password) in Site
integrations → E-mail sending and use **Send test e-mail**; on the deployed domain empty the SMTP fields again; with Turnstile test keys the widget is visible, without a token the submission is rejected;
`node .agents/skills/iapl-consent-check/scripts/consent-check.mjs http://localhost:3000/pl` = 0 errors;
after a choice in the banner a new record in Consent records.
@@ -637,7 +644,11 @@ scaling (5). `●` routes for pages need the database at build time (PROGRAMISTA
5. **Cookies**: banner texts, Privacy link label, Policy version, Cookies (import from the scan), Detail labels —
in every language.
6. **Notifications**: form messages in every language.
7. **Site integrations**: SMTP or Graph (From Name/Address; Send test), Turnstile (for testing site
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 the built-in mail
service" ("waiting for approval" = ask Intecion to approve the host), then **Send test e-mail** → "through the built-in
mail service". 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.
@@ -645,7 +656,7 @@ scaling (5). `●` routes for pages need the database at build time (PROGRAMISTA
**Deployment (Coolify — the only path; the user/team does it, you prepare the inputs).** Full procedure:
`node_modules/@intecion/ipal-kit/docs/deployment.md` §4. Hand over:
- the env list for the Coolify app, each marked **build time** and/or **runtime** — `NEXT_PUBLIC_*` both; secrets
(`PAYLOAD_SECRET`, `R2_*`, `GRAPH_*`, `TURNSTILE_SECRET_KEY`, `IAPL_IP_HEADER`) runtime; `DATABASE_URI` /
(`PAYLOAD_SECRET`, `R2_*`, `TURNSTILE_SECRET_KEY`, `IAPL_IP_HEADER`) runtime; `DATABASE_URI` /
`PAYLOAD_SECRET` also build time when pages are prerendered from the database (§3a3);
- domains `https://client.pl,https://www.client.pl` with the www ↔ apex redirect matching `NEXT_PUBLIC_SERVER_URL`;
port 3000; health check `/api/health`;
+31 -2
View File
@@ -535,8 +535,8 @@ Every name from before keeps working: `ipalKit()` and the other old exports, the
`ipal-doctor.json`, `ipal-audit-skip`, the old pointer block. The package is still `@intecion/ipal-kit`; routes
`/api/ipal/*`, `--ipal-*` tokens, `data-ipal` hooks and the cookie `ipal_vid` are unchanged (AGENT.md "Names: IAPL and
ipal-kit"). **Do not rename anything in the project unless the owner asks.**
1. Update the package, `pnpm install`. No option, schema, migration or import-map change (`pnpm payload generate:importmap`
gives no diff).
1. Update the package, `pnpm install`. The rename itself changes no option, schema, migration or import map; the mail
service of the same release adds one admin component — see the next block.
2. Refresh the skills: `pnpm exec iapl-skills` (the project's `ipal:skills` script, where it has one, runs the same program). It
installs `iapl-*`, removes the 16 old `ipal-*` folders by name (a skill of the project's own named `ipal-…` stays),
and rewrites the pointer block in `AGENTS.md` in place. Commit the result. Old skill names written by hand in
@@ -552,6 +552,35 @@ ipal-kit"). **Do not rename anything in the project unless the owner asks.**
**Check:** `pnpm exec iapl-doctor` shows no new error or warning (new rules: `legacy-names`, `storage-names`); the site
builds; the panel opens; the old commands (`pnpm exec ipal-doctor`) still run.
**→ 1.17.0, e-mail (the Intecion mail service is the default transport; Microsoft Graph deprecated; CHANGELOG 1.17.0;
PROGRAMISTA §6, item 73; email.md; AGENT.md §7.2) — one command for every site, then read which case the site is:**
1. **Every site:** `pnpm payload generate:importmap` and commit — the e-mail tab has a new component
(`@intecion/ipal-kit/admin#MailRelayStatus`); with a stale map the block "How e-mails are sent" is blank. No schema
change, no migration.
2. **Which case** — Site integrations → E-mail sending, and the Coolify env:
- **SMTP filled in** (server, user name, password): nothing changes, the site contacts nobody. Done.
- **`GRAPH_*` set:** mail as before; one deprecation warning per start, doctor warning `mail-graph-deprecated`.
Do **not** remove the variables in passing — moving the site is the owner's decision (email.md "Moving off
Microsoft Graph"). Note: with `GRAPH_*` set and SMTP filled in, the panel's choice decides as before.
- **Neither** (mail failed with "not configured" until now): **on its next e-mail the site contacts
`webservices.intecion.net` with its host and the plugin version**, receives its own token through the new public
route `POST /api/iapl/mail-relay/confirm`, and from then on sends from `[email protected]`
under the panel's "Sender name". Agree it with the owner **before** the deploy; to keep the old behaviour:
`iapl({ mail: { relay: false } })`.
3. **For a site that will use the mail service:** `serverURL` is the public address the site answers on without a
redirect; no proxy or WAF rule blocks `/api/iapl/mail-relay/confirm`; `trailingSlash: true` or another `routes.api` →
Intecion sets the site's confirm address first; "Sender address" is filled in (replies go there); Intecion has listed
the host (otherwise "waiting for approval"); the client's processing agreement names the service.
4. Code that compared the result of `payload.sendEmail` needs no change for SMTP and Graph. A send through the mail
service returns `{ sent, transport: 'relay', … }`; `sent: false` with `confirmed: false` means "may have been sent".
5. Your own account mail (invitations): mark it — `withMailKind(message, 'account')`. Form mail and Payload's
"forgot password" are marked by the plugin.
**Check:** `pnpm exec iapl-doctor --deep --url <site>` → no `mail-transport` / `mail-relay-state` / `mail-reply-address` /
`mail-relay-route` finding (or only `mail-graph-deprecated` on a Graph site); Site integrations → E-mail sending →
**Send test e-mail** names the transport you expect; a form submission arrives. **The service has to be live for a site
without SMTP: until Intecion says so, such a site reports `relay-unreachable` and sends nothing — keep SMTP, or
`relay: false`.**
## 2. Inventory (no code changes)
**What changed for projects** between your old and new plugin version is exactly the reference site's diff —
`git diff v<old> v<new> -- reference/` in the IAPL repo (or the two `docs/agent/reference-site/INDEX.md` files):
+23 -4
View File
@@ -9,7 +9,7 @@ zones. This page describes that one path (§4); other hosts — a short note at
Coolify labels below may differ slightly between Coolify versions.
Related: [PROGRAMISTA.md](./dev/PROGRAMISTA.md) (from zero to a working site, §4 deployment),
[env.md](./env.md) (validation at startup), [storage.md](./storage.md) (R2), [email.md](./email.md) (Graph),
[env.md](./env.md) (validation at startup), [storage.md](./storage.md) (R2), [email.md](./email.md) (the mail service, SMTP),
[security.md](./security.md), [integrations.md](./integrations.md) (integration status in the panel).
---
@@ -43,7 +43,23 @@ derives its signing key from it (`sha256(secret)`, first 32 hex characters). Cha
IAPL itself derives nothing from it. Change it only with the owner's OK, at a quiet time, and tell the editors
they will have to log in again.
### Email — Graph (OPTIONAL, agency-level, when transport = Graph)
### Email — nothing in env
Mail needs **no variable**. A site with no SMTP server in the panel sends through the Intecion mail service
([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
calls the site back at `https://<host>/api/iapl/mail-relay/confirm` and follows no redirect: with a www ↔ apex
redirect in Coolify, `serverURL` names the side that answers).
- **That route reachable from the internet** — no basic auth on the Coolify app, no firewall or WAF rule in front of
`/api/iapl/`; behind Cloudflare leave it uncached and unchallenged.
- **Outbound HTTPS** to `webservices.intecion.net`.
- A staging copy on its own domain enrols as its own site (its own token, its own limits, its own approval); a
staging copy that must not send: `iapl({ mail: { relay: false } })` or SMTP to a catcher.
- Several containers of one site share the database, so they share the token; a restore of an old database dump
brings back an old token — the site then enrols again by itself on its next e-mail.
### Email — Graph (deprecated since 1.17.0, removed in 2.0; only for sites that already use it)
```bash
GRAPH_TENANT_ID=<azure-tenant-id>
@@ -435,7 +451,7 @@ Files on forms are e-mailed, not stored — **no volume and no bucket** for them
### Integrations in the panel
Mail (SMTP/Graph) and Turnstile errors are visible in the panel after deploy: an alert on the dashboard and a banner on
Mail (the mail service, SMTP, Graph) and Turnstile errors are visible in the panel after deploy: an alert on the dashboard and a banner on
the Site integrations tab — see [integrations.md](./integrations.md).
### Other hosts
@@ -484,7 +500,10 @@ checks with `dig` after propagation. Check on the zone's authoritative server
**Which domain gets SPF/DKIM/DMARC (rows 6–8)** — the one in the **From** address of sent mail:
- **SMTP from the panel** transport → the domain from the *From address* field in Site integrations (usually the client's
domain); the records come from that mailbox's provider;
- **Graph** transport → From is always `GRAPH_SENDER` (agency mailbox, [email.md](./email.md)) —
- **The Intecion mail service** (the default) → From is always `[email protected]`:
SPF/DKIM/DMARC are Intecion's, set once for that domain. **Nothing is added to the client's DNS zone for it**; the
address from the panel goes into Reply-To;
- **Graph** transport (deprecated) → From is always `GRAPH_SENDER` (agency mailbox, [email.md](./email.md)) —
SPF/DKIM/DMARC are set once for the agency domain, not per project; the address from the panel goes into Reply-To.
Without SPF+DKIM aligned with the From domain (DMARC alignment) form mail lands in spam
+1
View File
@@ -680,6 +680,7 @@ Do one item at a time, build, check. Order by importance:
| 70 | **1.16.7** — `next build --webpack`: `'server-only' cannot be imported from a Client Component module`, from a `'use client'` file that imports `isAdmin`, `isEditor` or `hasMinimumRole` | Import them from `@intecion/ipal-kit/client` in client components, keep the second argument (`isAdmin(user, config)`); `import type` may stay on the main entry | CHANGELOG 1.16.7, access.md |
| 71 | **1.16.8 — security** — a site built with Turbopack (`next build` without `--webpack`) serves `/_next/static/media/package.<hash>.json`; or the project has a staff collection of its own without access rules; or a plugin listed after iapl copies a staff collection or sets `admin.user`; or the start log says `No staff account holds the role "admin", so NOBODY can …` | Update, `pnpm exec iapl-skills`, `rm -rf .next`, rebuild; no option, schema, migration or import map. Turbopack: `find .next/static -name 'package*.json'` empty, purge a CDN. Own staff collection: a `roles` list that can hold `editor` / `admin` → only an admin manages its accounts (write own rules otherwise; one account must hold `admin`); a single select with only `user` / `editor` / `admin` → its accounts manage each other again (own rules if your code goes by the value). A copy: `access.update: adminOrSelfIn('copy')`, or `custom.ipal.accountRules: false` | CHANGELOG 1.16.8, access.md "Account rules" |
| 72 | **1.17.0 — the plugin is called IAPL** — you see `iapl()`, `iapl-doctor`, `IAPL_IP_HEADER`, `iapl-doctor.json`, `[iapl]` in docs and logs and wonder whether the project must change | No. Every old name works through 1.x (`ipalKit`, `ipal-*` commands, `IPAL_*` env, `ipal-doctor.json`, `ipal-audit-skip`, the old pointer block); the package is still `@intecion/ipal-kit`. Run `pnpm exec iapl-skills` (or the project's `ipal:skills` script) and commit; change a log filter on `[ipal]` to `[iapl]`. Rename the rest only when the owner asks (`iapl-upgrade` "→ 1.17.0", AGENT.md "Names: IAPL and ipal-kit"). Never set `storageNames: 'iapl'` on an existing site |
| 73 | **1.17.0 — e-mail: the Intecion mail service is the default transport** — a site with no SMTP server in the panel and no `GRAPH_*` starts sending through the service after the upgrade (an outbound call with its host; a new public route `POST /api/iapl/mail-relay/confirm`; mail from `[email protected]`); the e-mail tab is blank where "How e-mails are sent" should be; a Graph site warns at start | `pnpm payload generate:importmap` and commit (new component `MailRelayStatus`). SMTP site: nothing else. Graph site: nothing now — deprecated, move when the owner says. Site with neither: agree it with the owner; `serverURL` = the public address, "Sender address" filled in, the host listed by Intecion; or `iapl({ mail: { relay: false } })` to keep the old behaviour | `iapl-upgrade` "→ 1.17.0, e-mail", AGENT.md §7.2, email.md |
After updating the package: `pnpm exec iapl-skills` (new skill versions), `pnpm payload generate:importmap`, `rm -rf .next`, restart dev, grep for the new symbol in
`node_modules/@intecion/ipal-kit/dist`.
+10 -1
View File
@@ -66,9 +66,13 @@ Added by `iapl` and **off until the site has `IAPL_DOCTOR_TOKEN`** (at least 32
returns counts only — never names, e-mails or values:
```json
{ "node": "v22.20.0", "openSignUp": [], "pendingCookies": 0, "plugin": "1.15.0", "staffOnOwnRoles": [], "staffOpenToOthers": [], "turnstile": null, "turnstileSecretFromEnv": false, "usersSetupClosed": 0, "usersWithout2fa": 0 }
{ "mail": { "graphEnv": false, "relay": { "connected": true, "disconnected": false, "nameReplaced": false, "state": "active" }, "replyAddress": true, "status": null, "transport": "relay" }, "node": "v22.20.0", "openSignUp": [], "pendingCookies": 0, "plugin": "1.15.0", "staffOnOwnRoles": [], "staffOpenToOthers": [], "turnstile": null, "turnstileSecretFromEnv": false, "usersSetupClosed": 0, "usersWithout2fa": 0 }
```
`mail` (since 1.17.0): the e-mail transport in effect, the recorded state of sending and the site's state with the
Intecion mail service — states and codes only, never a token, a password or an address; `relay` is `null` when the
mail service is switched off.
Turn off: `iapl({ doctor: false })`. Adapt: `iapl({ doctor: { tokenVar: 'MY_TOKEN', access: ({ req }) => isAdmin(req.user, req.payload) } })` (a logged-in staff admin may read it too; the second factor is checked for you — never test `req.user.roles` by hand, an account of another collection can carry the same value)
(`access` lets a logged-in admin read it without the token). Building blocks: `buildDoctorEndpoint`,
`collectDoctorStatus` from `@intecion/ipal-kit/doctor`.
@@ -108,6 +112,11 @@ 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-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, the sender name not replaced (warning); not enrolled yet (info) |
| | `mail-reply-address` | warning | (deep) on the mail service, "Sender address" is filled in: replies go there |
| | `mail-graph-deprecated` | warning | Microsoft Graph is not in use: no `GRAPH_*` variables on the site (deep), no `graphAdapter` / `emailGraph: true` in the config — deprecated, removed in 2.0 |
| | `mail-relay-route` | warning | nothing keeps the mail service from confirming the site: no `trailingSlash: true`, `routes.api` is `/api` (else Intecion sets the site's confirm address); live, on the mail service: `/api/iapl/mail-relay/confirm` answers without a redirect, a block or a server error. Skipped with `relay: false` |
| admin | `admin-meta` | warning | IAPL ≥ 1.14.5, no `adminMeta: false` / `agency: false`; live: the admin `og:image` is `/api/ipal/admin-og` |
| | `admin-noindex` | error | (live) the admin login page is noindex |
| agents | `agents-md` | error / warning | `AGENTS.md` with a non-empty `## Project decisions`, the `iapl:start…end` pointer for the installed version, `CLAUDE.md` with `@AGENTS.md` |
+426 -118
View File
@@ -1,12 +1,352 @@
# email
Sending mail with two transports to choose from: **SMTP from the panel**
(`panelSmtpAdapter`, universal) or **Microsoft Graph** (`graphAdapter`,
through Exchange/M365). Both implement the same `PayloadEmailAdapter` interface,
so `payload.sendEmail` and form mail work whatever the choice.
The project wires the adapter in `buildConfig({ email })` (the recommended dispatcher is `mailAdapter()`),
and the editor picks the transport in the panel. A separate `sendEmail` helper (from `/server`) sends
**always through the SMTP** from the panel, bypassing the adapter.
Mail works with **no setup**: a site with no SMTP server in the panel sends through the
**Intecion Notifications Webservice** (below: "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` |
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.
A separate `sendEmail` helper (from `/server`) sends **always through the SMTP** from the panel.
## Wiring
```ts
// payload.config.ts
import { iapl, mailAdapter } from '@intecion/ipal-kit'
export default buildConfig({
serverURL: process.env.NEXT_PUBLIC_SERVER_URL, // the site's public address: the mail service calls it back
email: mailAdapter(),
plugins: [iapl({ /* mail: { relay: … } — only to change a default, see "Options" */ })],
})
```
The plugin does **not** set `config.email` — without `email:` Payload uses a mock that only logs to the console.
## Which transport a send takes
Decided on every send from Site integrations → E-mail sending, with no stored value of its own
(`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).
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.
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.
- **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
A service run by Intecion that sends mail for its clients' sites. A site holds **no mail key and no
password**: it gets its own token by proving that it is served at its host. Nothing is typed anywhere.
### The first send (enrolment)
1. The site makes a random nonce, keeps its hash for 5 minutes and calls
`POST https://webservices.intecion.net/mail/v1/enrol` with `{ host, nonce, product: 'iapl', productVersion }`.
**This is the first outbound call: it carries the site's host and the plugin version, nothing else.**
2. Before it answers, the service calls the site back:
`POST https://<host>/api/iapl/mail-relay/confirm` with the nonce and a token.
3. The site's confirm route accepts the call only when it holds exactly that nonce, stores the token and answers
with a hash of both. Only then does the token become valid.
4. The message is sent. Later sends skip all of this.
What the site needs for it:
- **`serverURL`** in the Payload config, with the public host the site really answers on (`https://example.com`,
not a host that redirects to `www`). Another host: `mail: { relay: { host: 'www.example.com' } }`.
- **The confirm route reachable from the internet**, at exactly `/api/iapl/mail-relay/confirm`, over HTTPS on port
443, **without a redirect** — the service follows none. No basic auth, no firewall rule, no maintenance page in
front of it. (Coolify: nothing to set; the route is part of Payload's API.)
- **Outbound HTTPS** from the server to `webservices.intecion.net`.
- A host Intecion has **listed** is active at once. Any other host is enrolled but **waits for approval**: mail is
not sent until Intecion approves it, then the same token works. The panel says which it is.
A site on `localhost`, on a private address or without `serverURL` is refused **by the plugin itself**, before any
call leaves the server — development machines do not contact the service. To test mail locally use SMTP (a local
catcher such as Mailpit) or the fake service ("Testing").
### What leaves the server
- At enrolment: the host and the plugin version.
- With every message: recipients, subject, text and HTML, attachments, the sender name, the reply address, the
kind of the message, and an idempotency key. The service keeps a log of metadata only (no subject, body,
attachment, reply address or recipient address) for 30 days.
- The service adds `X-Intecion-Site: <host>` and `X-Intecion-Product: iapl` to every mail.
- Recipients' addresses and message bodies pass through Cloudflare (the service's mail back end). Name it in the
client's processing agreement before a client site sends through the service.
### Sender name and reply address
- **Sender name:** `mail.relay.senderName`, else the panel's "Sender name", else the site name from Site
settings; with none of them the mail leaves under the site's host (`relaySenderName(payload, options, panelName)`).
- The service checks the name: at most 64 characters, letters of one script, no address, no name of a mailbox
provider, bank or "support". **A name it does not accept is not a failed send** — the mail leaves under the
site's host, the result carries `warnings: ['sender-name-replaced']`, and the panel's state block shows the name
that was used so the client can choose another. The check errs on the careful side and can replace an honest
name that reads like a web address ("Dom.Pl").
- **Reply address:** the message's own `replyTo` (a form sets one), else the panel's "Sender address". The
service's sender address has no mailbox: **fill in "Sender address"**, or replies are lost (the doctor warns:
`mail-reply-address`).
- `from` and free headers of a message are ignored: the service fixes the sender address and takes no header.
### Limits
The numbers are the service's, per site, and can be changed by Intecion for one site. Defaults:
| Limit | Default | Applies to |
|---|---|---|
| Messages an hour / a day | 30 / 200 | everything but security alerts; mail other than account mail may use four fifths (24 / 160) |
| Recipients a message | 10 | To, CC and BCC together |
| Confirmations to one address a day | 10 | a form's confirmation to an address a visitor typed |
| New addresses a day | 50 | addresses the site has not written to for 30 days |
| Files in one message | 10 MB, 20 files | read by the plugin from the service; programs and scripts are refused |
| Text and HTML together | 500 kB | |
A message over a limit is refused whole (`relay-quota`, `relay-too-large`); the site is not suspended for it.
`mailAttachmentLimit(payload)` reports the file limit the service named, so a form's File field never promises
more ([forms.md](./forms.md) "Files"); until the site has enrolled it is `null` (the plugin has no number of its own).
**Account mail is limited by the site itself.** "Forgot password" is a visitor's lever like a form, and the
service lets account mail use the whole hour. So the relay transport holds back more than **5 account e-mails to
one address** and more than **10 asked for by one visitor** within an hour (`mail.relay.accountMail`:
`{ perAddress, perVisitor, windowMinutes }`, or `false`). A held-back message is reported as `relay-quota` in the
log and the panel; the visitor is told nothing. Pin the address header for it: `IAPL_IP_HEADER`
([security.md](./security.md)).
### What a message is (kinds)
The service limits kinds differently, so every message says what it is — truthfully:
| Kind (`MailKind`, list: `MAIL_KINDS`) | Who sets it |
|---|---|
| `form-notification` | the plugin: a form's e-mail whose every recipient is an address written in the panel |
| `form-confirmation` | the plugin: a form's e-mail to an address a visitor typed (`buildFormMailKindHook`) |
| `account` | the plugin: Payload's "forgot password", and "verify your e-mail" where the collection verifies addresses |
| `test` | the plugin: the test e-mail from the panel |
| `security-alert` | nothing yet. The service addresses these itself (to Intecion); recipients are ignored |
| `system` | everything else: mail whose purpose is not known, your own `payload.sendEmail` |
Your own mail:
```ts
import { runWithMailKind, withMailKind } from '@intecion/ipal-kit'
// one message
await payload.sendEmail(withMailKind({ to, subject, html }, 'account')) // an invitation to an account holder
// everything sent inside
await runWithMailKind('account', () => sendWelcomeMails(payload, user))
```
- `mailKindOf(message)` reads the mark (the key is the symbol `MAIL_KIND`; other transports ignore it).
- `mail.relay.kind: (message) => MailKind | undefined` decides for messages nobody marked.
- `expectMailTo(address, kind, { visitor })` says what the **next** message to one address is, for mail a library
composes by itself; the plugin uses it for Payload's account mail. It lasts ten seconds and one message.
- Mark `account` only for mail to an account holder, and `form-confirmation` for mail to an address a visitor typed.
A wrong kind gives a visitor room the service did not mean to give.
### Retry, and "not confirmed"
- A message is encoded **once**; exactly those bytes go out on every attempt, under one `Idempotency-Key`. At most
**three attempts**, 30 seconds each, at most ten seconds of waiting between them in all — and only after an answer
the service marks retryable, or after no answer. An enrolment on the way is not one of the three.
- **No answer at all** (time-out, connection lost) is reported as `relay-not-confirmed` with `confirmed: false`: the
message **may have been sent**. Sending the same message again within 24 hours reuses the same key, so the
service answers with what happened to the first attempt (`replayed: true`) and no second mail goes out.
- The form **keeps working** meanwhile — the submission is saved in Form Submissions; only the mail is missing.
- There is no stored outbox: a message that failed is not sent later by itself.
### The token
- Kept in Payload's key-value store (`payload.kv`, the `payload-kv` collection Payload itself adds; key
`RELAY_KV_KEY` = `iapl:mail-relay`). **No field, no column, no migration.** That collection refuses every
operation through access control and is hidden in the panel, so the token cannot be read over REST or GraphQL —
not by an admin either. It is never logged and never sent to a browser.
- The token works only from the server addresses the site enrolled from. After a move to another server the
service answers "enrol again"; the site does, by the same call-back, and sends. A site whose requests leave from
many changing addresses (serverless, a pool of egress addresses) needs its limit of addresses raised by Intecion.
- **Rotation:** every 90 days the service says the token is due; the site asks for a new one before its next send
and stores it at once. The previous token works for 24 hours more, so several containers of one site do not cut
each other off (they share the database). `rotateRelayToken(payload)` does it now.
- **A lost token heals itself:** the next send enrols again.
- **Disconnect:** "Disconnect" in the panel (`disconnectRelay(payload)`) gives the token up on the service and stops
the site from enrolling by itself until "Connect again" (`enrolRelay(payload, { force: true })`).
- **A token issued by hand** — for a site the service cannot call back (behind a firewall): Intecion issues one,
an admin enters it in the state block ("Enter an access key"), or a script calls `setRelayToken(payload, token)`.
- Encryption at rest: none, like `smtpPassword`. A token read from a database dump is of little use — it does not
work from another server address.
### The state block in the panel
Site integrations → E-mail sending starts with "How e-mails are sent" (component `MailRelayStatus`, import-map
entry `@intecion/ipal-kit/admin#MailRelayStatus` — **run `payload generate:importmap` after upgrading**): the
transport in effect; for the mail service the state (connected, waiting for approval, stopped, not connected and
why), the address mail leaves from, where replies go, what is left of the hour and the day, and a sender name the
service replaced. Buttons: **Check now**, **Connect again**, **Disconnect**, **Enter an access key**.
Routes (all three need the `admin` role: not logged in → 401, other role → 403; none ever answers with a token):
| Route | What |
|---|---|
| `GET /api/iapl/mail-relay/status` | the transport and the stored state; `?refresh=1` asks the service |
| `POST /api/iapl/mail-relay/connect` | enrol now; with `{ token }` store a token issued by hand |
| `POST /api/iapl/mail-relay/disconnect` | give the token up |
| `POST /api/iapl/mail-relay/confirm` | **public** — the service's call-back. `404` and no change unless the site itself started an enrolment in the last 5 minutes; rate-limited (10 a minute per address, `mail.relay.confirmRateLimit`) |
These are the first routes under `/api/iapl/`; the others stay under `/api/ipal/` until 2.0. The confirm path is
fixed by the service for this product — a project cannot move it. For your own panel:
`relayPanelEndpoints()`, `mailPanelState(req, undefined, { refresh })` (type `MailPanelState`), `getRelayStatus(payload, { refresh })`
(type `RelayStatus`).
### Status codes
`mailAdapter()` records a failed send in `emailStatus` (banner on the tab, alert on the dashboard). The codes of
the mail service (`RELAY_STATUS_CODES`, type `RelayStatusCode`; `relayStatusFor(code, retryable)` maps a code of
the service), each with a text in the editor's language:
| Code | Meaning | What to do |
|---|---|---|
| `relay-pending` | enrolled, waiting for approval by Intecion | Intecion approves the host; nothing to do on the site |
| `relay-suspended` | stopped by Intecion | contact Intecion; SMTP in the panel sends meanwhile |
| `relay-refused` | the site could not enrol | "When the site cannot be confirmed" below |
| `relay-disconnected` | an admin pressed "Disconnect" | "Connect again", or fill in SMTP |
| `relay-quota` | a limit of the site or of the whole service; too many recipients; the site's own limit on account mail | wait; ask Intecion for other limits; SMTP for a site that sends more |
| `relay-too-large` | text or files over the service's limit | a smaller file; `forms.attachments.maxFileSize`; SMTP |
| `relay-attachment-refused` | a file type the service never carries (programs, scripts), or a bad file name | send without that file |
| `relay-recipient-suppressed` | the back end refuses one recipient (its mailbox bounced or complained before, for any site). Nothing was sent to anybody | correct the address; ask Intecion to clear it |
| `relay-unreachable` | the service or its back end failed or could not be reached; "probably not sent" | try again; if it persists, SMTP |
| `relay-not-confirmed` | no answer: the message may have been sent | check the mailbox before sending again |
| `relay-error` | the service refused the request as wrong, or the message has no recipient or body | a bug: report it with the server log |
| `relay-name-replaced` | (a warning in the state block, not a failure) the sender name was replaced | choose another "Sender name" |
The result of a send through the service (`RelaySendResult`): `{ sent: true, transport: 'relay', id, messageId?, kind, replayed, senderName, warnings }`
or `{ sent: false, transport: 'relay', code, cause, confirmed, error, detail }` — `cause` is the service's own
code, `detail` is for the log and the panel, never for a visitor.
### When the site cannot be confirmed
`relay-refused` with the cause `callback-failed` and a reason:
| Reason | Usual cause | Fix |
|---|---|---|
| `unreachable`, `timeout` | a firewall, a private network, the wrong public host | open the route, or set `serverURL` / `mail.relay.host` to the host the site answers on; a site that cannot be reached at all gets a token by hand |
| `redirect` | `trailingSlash: true` in `next.config`; `example.com` redirecting to `www.example.com`; a redirect by language | enrol the host that answers without a redirect; for trailing slashes ask Intecion to set the path ending in `/confirm/` |
| `status` | the route is missing, blocked, or the API is served at another path (`routes.api`) | ask Intecion to set this site's confirm address; check that no proxy rule blocks `/api/iapl/` |
| `confirmation` | something prints around the JSON answer (a proxy that rewrites responses) | take it out of the way for this route |
After a refusal the site does not ask again by itself for 15 minutes (a call-back that times out costs 8 seconds a
message); "Connect again" asks at once. Other causes: `host-not-allowed` (not a public DNS name),
`enrolment-closed` (the service takes no new sites).
### Options
`iapl({ mail: { relay } })` (`MailOptions`, `RelayOptions`); `mailAdapter({ relay })` overrides it for that adapter
(`resolveRelayOptions(payload, own)` gives the options in effect).
| Option | Default | What |
|---|---|---|
| `relay: false` | — | switches the mail service off: no enrolment, no outbound call, no confirm route, no state block, the panel wording of 1.16 |
| `url` | `RELAY_BASE_URL` (`https://webservices.intecion.net/mail`) | another base address — a relay of your own that speaks the same contract |
| `host` | host of `serverURL` (`relayHost(payload, options)`) | the public host the service calls back |
| `enrol` | `'auto'` | `'manual'`: only "Connect again" or `enrolRelay()` enrols. `false`: never (the token comes from `token` or `setRelayToken`) |
| `token` | — | a token from elsewhere (`string` or a function): the stored token is not used and the site does not enrol |
| `senderName` | panel, then site name | a fixed name, or a function |
| `kind` | — | the kind of a message nobody marked |
| `accountMail` | `{ perAddress: 5, perVisitor: 10, windowMinutes: 60 }` | the site's own limit on account mail; `false` = none |
| `confirmRateLimit` | `{ max: 10, windowMs: 60000 }` | calls to the public confirm route per address |
| `timeoutMs` | `30000` | one attempt of a send |
| `retryBackoffMs` | `1000` | the wait before the next attempt when the service names none (times the attempt's number) |
| `fetchImpl` | `fetch` | for tests |
| `graphDeprecationWarning` (on `mail`) | `true` | `false` silences the start warning of a site on Microsoft Graph |
Fixed values are in `RELAY_DEFAULTS`; `RELAY_CONTRACT_VERSION` is the version of the wire contract the client
speaks, `RELAY_PRODUCT` its product name (`iapl`), `RELAY_SERVICE_NAME` the service's name, `RELAY_CONFIRM_PATH`
the confirm path under the API route, `RELAY_SENDER_ADDRESS` the sender address until the service has been asked.
### Turn off, your own relay, the transport alone
- **Off:** `iapl({ mail: { relay: false } })`. The site then sends only through SMTP (or Graph), as before 1.17.0.
Use the plugin option, not only `mailAdapter({ relay: false })`: the option also removes the routes and the state block.
- **A relay of your own:** `mail: { relay: { url, token: () => process.env.MY_RELAY_TOKEN, enrol: false } }`, or
keep the call-back enrolment if your relay speaks it. The wire format is the contract copied in the repository
(`contracts/mail-relay/`), typed as `RelaySendRequest`; `buildRelayMessage(message, { kind, senderName, replyTo })`
(`BuildRelayMessageArgs`, `BuiltRelayMessage`) builds a request from a Payload message, `bareAddress` /
`bareAddresses` and `cleanSubject` are its parts, `relayRequest(call)` (`RelayCall`, `RelayAnswer`,
`RelayRefusal`) is one HTTP call, `sendThroughRelay(payload, options, message, context)` (`RelaySendContext`)
one message with the retry rule, `isPublicHost(host)` the check of a host.
- **The transport alone:** `email: relayAdapter()` (`RelayAdapterArgs`) — the mail service and nothing else, with the
panel's sender name and reply address when Site integrations exists. `relayAttachmentLimit(payload, options)` is
its file limit.
- **The confirm route alone:** `relayConfirmEndpoint()`, for a project that builds its own config without `iapl()`.
- **Your own e-mail adapter:** `email:` in `buildConfig` is the project's and wins over everything here ("Your own
e-mail adapter" below).
### Testing
`createFakeRelay()` is the service in memory (`FakeRelay`, `FakeRelayOptions`, `FakeRelayMail`,
`FakeRelayLimits`): it speaks the contract — every example of the contract runs against it in the plugin's own
tests — and records accepted mail instead of sending it.
```ts
import { createFakeRelay, mailAdapter } from '@intecion/ipal-kit'
const relay = createFakeRelay({ allow: ['example.com'], callSite: (url, init) => myApp.fetch(url, init) })
// config: email: mailAdapter({ relay: { url: relay.url, fetchImpl: relay.fetch } })
await payload.sendEmail({ to: 'a@example.org', subject: 'Hi', html: '<p>Hi</p>' })
expect(relay.outbox[0]).toMatchObject({ kind: 'system', to: ['a@example.org'] })
```
- `allow` / `relay.allow(host)`: hosts that are active at once; others wait for approval. `relay.setSite(host, state)`,
`relay.issueToken(host)`, `relay.backend = 'failure'`, `relay.intercept`, `relay.limits`, `relay.clientAddress`
arrange what a test needs; `relay.listen(port)` serves it over HTTP for a site in another process
(`allowLocalHosts: true` lets it call back `http://localhost:<port>`).
- It is **not** the service: its sender-name check and its limits are simplified. Test what the site does with each
answer, not what the service accepts.
## 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.
- **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").
- The address and name from the panel always win over the message's `from`. CR/LF characters are stripped from the
subject (protection against header injection through form-builder `{{field}}`).
- Missing SMTP config or a send error → the adapter **does not throw**, it returns `{ sent: false, error }` and logs.
- Port 465 → implicit TLS, others → STARTTLS.
- The adapter reads the config on every send, so changing the mailbox in the panel works without a restart.
SMTP only, without the dispatcher:
```ts
// payload.config.ts
import { panelSmtpAdapter } from '@intecion/ipal-kit'
export default buildConfig({
email: panelSmtpAdapter(),
// panelSmtpAdapter({ fallbackFromAddress, fallbackFromName }) — used only
// before the panel is filled in (Payload needs the address synchronously at
// startup, before the global can be read)
})
```
Options: `fallbackFromAddress` (`'noreply@localhost'`), `fallbackFromName` (`'Website'`).
## Dependency
@@ -20,18 +360,7 @@ install it (nodemailer 10 ships its own types, so `@types/nodemailer` is not nee
- **Since nodemailer 9**, attachments given as an `href`/`path` URL are fetched with TLS certificate validation.
A mail with an attachment from a host with a self-signed certificate now fails instead of sending.
## Config
No plugin options — SMTP (`smtpHost`, `smtpPort` (default 587), `smtpUser`,
`smtpPassword`, `smtpFromAddress`, `smtpFromName`) and `emailTransport` live in
SiteIntegrations (E-mail sending tab). The editor configures them in the panel.
- **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"). The plugin does **not** set
`config.email` — you wire the adapter yourself (below).
## Front — sendEmail (server)
## The sendEmail helper (server)
```ts
import { sendEmail } from '@intecion/ipal-kit/server'
@@ -63,46 +392,11 @@ if (result.sent) {
- Port 465 → implicit TLS, others → STARTTLS.
- `server-only` — the SMTP password never ends up in the browser bundle.
## Note: Payload system mail
## Payload system mail
Password reset / email verification go through Payload's built-in mechanism
(`config.email`), which the plugin does **not** set by itself. Wire
`mailAdapter()` / `panelSmtpAdapter()` in `buildConfig({ email })` (below) — then
this mail also goes through the mailbox from the panel, with no SMTP in env.
## Adapter — SMTP from the panel for all of Payload
`sendEmail` sends with its own transport. Separately, the plugin provides an adapter that
connects the same mailbox to `payload.sendEmail`:
`mailAdapter()` is recommended (below, "Wiring — choosing the transport") — it contains this
adapter and adds Graph. SMTP only:
```ts
// payload.config.ts
import { panelSmtpAdapter } from '@intecion/ipal-kit'
export default buildConfig({
email: panelSmtpAdapter(),
// panelSmtpAdapter({ fallbackFromAddress, fallbackFromName }) — used only
// before the panel is filled in (Payload needs the address synchronously at
// startup, before the global can be read)
})
```
Options: `fallbackFromAddress` (`'noreply@localhost'`), `fallbackFromName` (`'Website'`).
The address and name from the panel always win over the message's `from`. CR/LF characters are
stripped from the subject (protection against header injection through form-builder `{{field}}`).
Missing SMTP config or a send error → the adapter **does not throw**, it returns
`{ sent: false, error }` and logs.
Once wired, everything in Payload that sends mail goes through the SMTP from Site
Integrations — including the built-in form-builder mail (Forms → Emails), password
reset and account verification mail. The adapter reads the config on every
send, so changing the mailbox in the panel works without a restart.
Without an adapter Payload uses a mock that only logs to the console — form-builder
mail will not go out.
Password reset and e-mail verification go through Payload's built-in mechanism (`config.email`). With
`mailAdapter()` wired they take the same transport as everything else; with the mail service they are sent as
account mail ("What a message is").
## Masking secrets in the panel (MaskedField)
@@ -121,10 +415,31 @@ Works on any `text` field. After wiring it in a project you may need
> database protection — if the DB leaks, the secrets are readable.
## Adapter — Microsoft Graph (Exchange / M365)
## Microsoft Graph (Exchange / M365) — deprecated
Alternative to SMTP: sending through the Microsoft Graph API, through a mailbox in
your (agency) M365 tenant. All form mail from all
> **Deprecated since 1.17.0; removed in 2.0** (with Payload 4). It keeps working, unchanged, in every 1.x release.
> Nothing new is built on it. A site on Graph prints one warning at start (`GRAPH_DEPRECATION_NOTICE`; silence:
> `mail: { graphDeprecationWarning: false }`) and the doctor reports `mail-graph-deprecated`. `graphAdapter`,
> `GraphAdapterArgs` and `mailAdapter({ graph })` are marked `@deprecated`.
### Moving off Microsoft Graph
To the mail service (when the owner says so):
1. Upgrade; check that `serverURL` is the site's public address.
2. Intecion lists the host on the service (or approves it after the first send).
3. Remove the four `GRAPH_*` variables in Coolify and redeploy. If "Sending method" says Microsoft Graph, set it
to "Automatic".
4. Site integrations → E-mail sending → send a test e-mail: the answer says "through the built-in mail service".
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).
Going back is putting the variables back. To SMTP instead: fill in the SMTP fields, send a test, remove `GRAPH_*`.
A project that wants Graph after 2.0 brings its own adapter ("Your own e-mail adapter"): the 1.x Graph adapter
is two files of plain `fetch` that can be copied.
Sending through the Microsoft Graph API, through a mailbox in your (agency) M365 tenant. All form mail from all
projects goes through ONE sender mailbox (e.g. `[email protected]`).
### Config split (deliberate)
@@ -147,23 +462,6 @@ Options `graphAdapter({ fallbackFromAddress, fallbackFromName, largeAttachments,
the first two are placeholders Payload requires at startup; the other two are for attachments ("Attachments" below).
`fetchImpl` is for tests.
### Wiring — choosing the transport (recommended: `mailAdapter`)
```ts
// payload.config.ts
import { mailAdapter } from '@intecion/ipal-kit'
email: mailAdapter(), // SMTP or Graph — chosen in the panel, on EVERY send
```
`mailAdapter` is a dispatcher: it reads `emailTransport` from Site integrations on every
send (no value → `'smtp'`), so the switch in the panel works without a restart.
Graph only when all 4 `GRAPH_*` variables are in env — otherwise a clear log and
fallback to SMTP (mail is not lost silently).
Options: `fallbackFromAddress`, `fallbackFromName` (for both delegates), `smtp`
(`PanelSmtpAdapterArgs`), `graph` (`GraphAdapterArgs`).
Low-level (when the transport should be fixed in the config):
```ts
@@ -198,10 +496,18 @@ to the client's address. The OAuth token is cached in the process until a minute
## Attachments
`payload.sendEmail({ …, attachments: [{ filename, content: Buffer, contentType }] })` works on both transports
`payload.sendEmail({ …, attachments: [{ filename, content: Buffer, contentType }] })` works on every transport
(nodemailer's shape). Form files use it: a file a visitor attaches is e-mailed and never stored
([forms.md](./forms.md) "Files"). Base64 adds 37 %: a 10 MB file is a 13.7 MB message.
### The mail service
The service names its limit (10 MB in all files of one message, 20 files, unless Intecion set other numbers for the
site); the plugin reads it from the service and `mailAttachmentLimit(payload)` reports it. A message over the limit
is refused before it is uploaded (`relay-too-large`). Programs and scripts are refused by file name
(`relay-attachment-refused`). Content must be a `Buffer` or a string — a stream or a file path is not carried.
The test e-mail's 10 MB file is at the limit: it shows whether the site's limit is the default.
### SMTP
The adapter passes attachments straight to nodemailer; the plugin sets no limit. The limit is the **mail server's**,
@@ -267,36 +573,18 @@ The large path, step by step, and what happens when it fails:
- [ ] A file of 2.9–3.1 MB (both sides of the switch) arrives.
- [ ] Server log after a send: no `delete it by hand`.
## Transport switch — mailAdapter
`mailAdapter()` is a dispatcher: one adapter wired in the config, it picks the transport
(SMTP/Graph) on EVERY send by reading the setting from the panel. That is why
the switch works in the panel (Payload builds the adapter once at startup, so you cannot
swap separate adapters at runtime — the dispatcher delegates internally).
```ts
// payload.config.ts — ONE adapter, the choice happens inside
import { mailAdapter } from '@intecion/ipal-kit'
email: mailAdapter()
```
Panel → Site integrations → E-mail sending → **Sending method** (SMTP / Microsoft Graph).
The dispatcher reads this choice per send. Guard: if Graph is selected but the
secrets are missing in .env → log + fallback to SMTP (no silent failure).
## Test send — button in the panel
The E-mail sending tab has a **Send test** button: enter an address, click, and a test
mail goes out through the CURRENT transport (`payload.sendEmail`). It shows the result (✓/✗ with the error).
Tick **Attach a 10 MB test file** to check that the mail server takes a file of that size ("Attachments" above). Endpoint
The E-mail sending tab has a **Send test e-mail** button: enter an address, click, and a test mail goes out through
the CURRENT transport (`payload.sendEmail`). The answer names the transport ("through the built-in mail service,
as …", "through your SMTP server") and, for the mail service, the sender name that was used. Tick **Attach a 10 MB
test file** to check that a file of that size gets through ("Attachments" above). Endpoint
`POST /api/ipal/test-email`, body `{ to, attachmentMB? }` (`admin` role only — needs roles from the `access` option:
not logged in → 401, other role → 403, bad address → 400, failed send → 502).
not logged in → 401, other role → 403, bad address → 400, failed send → 502 with the reason in the admin's language).
Save your changes before the test — the endpoint reads from the database, not from the field on screen.
> The button shows only the adapter's short error (e.g. `Graph sendMail failed (403).`,
> `Failed to send email.`, `SMTP is not configured…`). The full Graph / SMTP response
> (`ErrorSendAsDenied`, `Insufficient privileges`, `535 …`) is in the **server logs**;
> for SMTP the detail also goes to the status banner (below).
> For SMTP and Graph the button shows only the adapter's short error; the full response (`ErrorSendAsDenied`,
> `535 …`) is in the **server logs**, and for SMTP the detail also goes to the status banner (below).
## Send status in the panel
@@ -304,26 +592,46 @@ Save your changes before the test — the endpoint reads from the database, not
while an error persists, immediately when the state changes). When sending fails:
- **Dashboard** — a red alert with the cause and a link to Site integrations,
- **Site integrations → E-mail sending** — a banner with the error (e.g. `SMTP: connect ECONNREFUSED …`,
`SMTP: SMTP is not configured…`, `SMTP: Invalid login: 535 …`,
`Microsoft Graph: Graph sendMail failed (403).`) and the time.
`SMTP: Invalid login: 535 …`, `Microsoft Graph: Graph sendMail failed (403).`, or the text of a mail service
code from "Status codes") and the time.
Only `mailAdapter` stores the status — `panelSmtpAdapter` / `graphAdapter` alone and
`mailAdapter` and `relayAdapter` store the status — `panelSmtpAdapter` / `graphAdapter` alone and
the `sendEmail` helper do not update it.
The form **keeps working** meanwhile — the submission is saved in Form Submissions,
only the mail did not go out. Graph selected in the panel without `GRAPH_*` in env → warning
"sent over SMTP". Changing the SMTP / transport fields in the panel clears the status; after the next
send (e.g. **Send test**) the current one appears.
only the mail did not go out. Graph selected in the panel without `GRAPH_*` in env and with SMTP filled in →
warning "sent over SMTP". Changing the SMTP / transport fields in the panel clears the status; after the next
send (e.g. **Send test e-mail**) the current one appears.
## Doctor
`iapl-doctor` ([doctor.md](./doctor.md)): `mail-transport` (nothing set up; sending is failing), `mail-relay-state`
(waiting for approval, stopped, refused, disconnected, a replaced sender name), `mail-reply-address`,
`mail-graph-deprecated`, `mail-relay-route` (trailing slashes, another API route, a redirect or a block in front of
the confirm route on the live site).
## Your own e-mail adapter
`email:` in `buildConfig` is the project's. Any Payload adapter works (`@payloadcms/email-nodemailer`, a provider's
SDK); you then skip the panel's SMTP fields, the mail service and the send status. To keep the plugin's parts:
- return `{ sent: false, error, detail? }` instead of throwing, and form files report the failure properly;
- add `attachmentLimit: () => number | null` to the adapter object, and `mailAttachmentLimit(payload)` and the
forms module respect it;
- `recordIntegrationStatus` writes `emailStatus` for the panel's banner;
- `panelSmtpAdapter()` and `relayAdapter()` are whole adapters you can delegate to.
## Turn off, override, extend
- **Turn off:** the plugin does not set `config.email` itself — without `email:` in `buildConfig` Payload uses
its mock (mail only in the console). The SMTP fields in Site integrations and the endpoint
`POST /api/ipal/test-email` are currently always added.
- **Choosing the transport:** `mailAdapter()` (the panel decides) or a fixed `panelSmtpAdapter()` /
`graphAdapter()`; any other Payload adapter (e.g. `@payloadcms/email-nodemailer`) also works —
then you skip the panel SMTP and the send status.
- **Override:** `fallbackFromAddress` / `fallbackFromName`, in `mailAdapter` separately `smtp` and `graph`
(`graph.largeAttachments: false` keeps Graph to attachments under 3 MB — "Attachments").
its mock (mail only in the console). The mail service: `mail: { relay: false }`. The SMTP fields in Site
integrations and the endpoint `POST /api/ipal/test-email` are always added.
- **Choosing the transport:** `mailAdapter()` (decided per send) or a fixed `relayAdapter()` /
`panelSmtpAdapter()` / `graphAdapter()`; any other Payload adapter also works.
- **Override:** `fallbackFromAddress` / `fallbackFromName`; in `mailAdapter` separately `relay`, `smtp` and `graph`
(`graph.largeAttachments: false` keeps Graph to attachments under 3 MB — "Attachments"); every option of the
mail service ("Options"); panel texts through `i18n.translations` (keys `mailRelay…`, `statusEmailRelay…`);
the tab's fields through `integrationsFields`.
- **Extend:** form mail content is modified by `forms.beforeEmail` (see [forms.md](./forms.md));
your own mail — `sendEmail` (SMTP) or `payload.sendEmail` (through the wired adapter).
your own mail — `payload.sendEmail` (through the wired adapter, marked with `withMailKind` when it is not
`system`) or `sendEmail` (always SMTP).
+1 -1
View File
@@ -60,7 +60,7 @@ use).
```ts
iaplEnvRules({
storage?: boolean | { requirePublicUrl?: boolean }, // R2_* (R2_BUCKET, R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY, R2_ENDPOINT; R2_PUBLIC_URL optional)
emailGraph?: boolean, // GRAPH_* (GRAPH_TENANT_ID, GRAPH_CLIENT_ID, GRAPH_CLIENT_SECRET, GRAPH_SENDER — e-mail)
emailGraph?: boolean, // DEPRECATED (Microsoft Graph, removed in 2.0): GRAPH_* (GRAPH_TENANT_ID, GRAPH_CLIENT_ID, GRAPH_CLIENT_SECRET, GRAPH_SENDER). E-mail needs no variable: email.md
cookieCrawl?: boolean, // IAPL_COOKIE_SCAN_URL (url), IAPL_COOKIE_SCAN_TOKEN (≥ 16 chars) — required in production; cookieScanner.crawl (cookie-scanner.md)
ipHeader?: boolean, // IAPL_IP_HEADER — required in production, optional outside it (header name [a-z0-9-])
turnstile?: boolean | { siteKeyVar?: string; secretVar?: string }, // NEXT_PUBLIC_TURNSTILE_SITE_KEY, TURNSTILE_SECRET_KEY
+5 -4
View File
@@ -276,8 +276,9 @@ characters, the extension of the detected type (`CV Jan Kowalski.pdf`; an empty
### Limits
- The limit a visitor sees and the server enforces is the lowest of: the field's value, `attachments.maxSizeMB`,
and what the e-mail transport can carry. On Microsoft Graph without the large-file path and without SMTP
settings that is about 2.8 MB ([email.md](./email.md) "Attachments"). The form document read through Payload
and what the e-mail transport can carry. With the Intecion mail service that is what the service reports (10 MB
unless Intecion set another number); on Microsoft Graph without the large-file path and without SMTP
settings about 2.8 MB ([email.md](./email.md) "Attachments"). The form document read through Payload
carries the result per File field in `resolved` (`maxSizeMB`, `maxTotalMB`, `maxFiles`, `accept`, `extensions`,
`typeLabels`) and `fileSubmitUrl` — `RenderForm` passes them on; nothing to wire.
- **Request size:** files do not go through the Server Action, so `serverActions.bodySizeLimit` (1 MB by default)
@@ -464,10 +465,10 @@ messages the editor configured (Forms → form → Emails), through
`payload.sendEmail`. For them to go out, the config needs an adapter:
```ts
email: mailAdapter(), // from '@intecion/ipal-kit' — SMTP or Graph according to the panel (email.md)
email: mailAdapter(), // from '@intecion/ipal-kit' — the mail service, or SMTP when the panel has a server (email.md)
```
Then they go through the transport chosen in Site integrations (SMTP or Graph). The editor sets recipients, subject and
Then they go through the transport in effect (the Intecion mail service, or the SMTP server from Site integrations). The editor sets recipients, subject and
body (placeholders: `{{field}}`, `{{*}}`, `{{*:table}}`) without touching the code.
`submitForm` is responsible only for Turnstile verification and storing. It stores the submission in the page's language
+9 -2
View File
@@ -3,7 +3,7 @@
External service keys edited in the admin panel, plus a notice for the editor when one of them
stops working — no crons, no polling: the server records the status when it actually uses an integration.
Related: [email.md](./email.md) (SMTP/Graph), [turnstile.md](./turnstile.md),
Related: [email.md](./email.md) (the mail service, SMTP, Graph), [turnstile.md](./turnstile.md),
[analytics.md](./analytics.md), [seo.md](./seo.md) (IndexNow), [deployment.md](./deployment.md).
## The `site-integrations` global (panel: Settings → Site integrations)
@@ -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 | `emailTransport` (`smtp` / `graph`), `smtpHost`, `smtpPort`, `smtpUser`, `smtpPassword`, `smtpFromAddress`, `smtpFromName`, test button, hidden `emailStatus` + banner |
| E-mail sending | the state block "How e-mails are sent" (`mailRelayStatus`, a `ui` field — nothing stored; absent with `mail: { relay: false }`), `emailTransport` (`smtp` = "Automatic" / `graph` = deprecated), `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 |
@@ -27,6 +27,8 @@ const integrations = await getSiteIntegrations<SiteIntegration>(payload) // ov
```
The "Send test" button (E-mail sending tab) calls `POST /api/ipal/test-email` (endpoint currently always added).
The state block above it reads `GET /api/iapl/mail-relay/status` and acts through `POST …/connect` and
`POST …/disconnect` (admin only; [email.md](./email.md) "The state block in the panel").
## Integration status — dashboard alert and tab banner
@@ -34,6 +36,10 @@ The "Send test" button (E-mail sending tab) calls `POST /api/ipal/test-email` (e
form (`turnstileStatus`) call `recordIntegrationStatus`. It writes only when the state changes,
or at most every 10 min while an error lasts; it never throws.
- **Changing keys in the admin panel** (Turnstile, `emailTransport` / `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
`payload-kv` and no route answers with it.
- **`IntegrationAlerts`** (`@intecion/ipal-kit/admin`) — the plugin always wires it into
`admin.components.beforeDashboard`: a list of integrations in the `degraded` state + Turnstile key
problems + an "Open Site integrations" link (from `adminRoute`). When everything works it renders nothing.
@@ -75,6 +81,7 @@ The dashboard `IntegrationAlerts` checks only `emailStatus` and `turnstileStatus
## Turn off / override
- The mail service's state block and its four routes: `iapl({ mail: { relay: false } })`.
- The `site-integrations` global, the `/api/ipal/test-email` endpoint and `IntegrationAlerts` on the dashboard
are **currently always added** — there is no option to turn them off. Workaround: a project plugin
wired after `iapl()` that removes / replaces the entry in `config.globals`, `config.endpoints` or
+1 -1
View File
@@ -69,7 +69,7 @@ pnpm exec iapl create intecion.com --dir ../intecioncom-web --answers answers.js
"languages": { "default": "pl", "locales": [{ "code": "pl", "label": "Polski" }, { "code": "en", "label": "English" }] },
"styling": { "primary": "oklch(0.5 0.17 250)", "fontBody": "Inter", "fontHeading": "Inter", "theme": "both", "defaultTheme": "system", "radius": "soft", "fluid": "wide" },
"content": { "pages": ["Home", "About", "Services", "Contact"], "collections": ["posts"] },
"forms": { "list": ["Contact form"], "recipient": "biuro@intecion.com", "transport": "smtp" },
"forms": { "list": ["Contact form"], "recipient": "biuro@intecion.com", "transport": "relay" },
"consent": { "tools": ["ga4"], "consentMode": "advanced", "banner": "detailed", "cookieScanner": true, "crawl": true },
"seo": { "aiBots": "allow", "localBusiness": { "type": "ProfessionalService" } },
"media": "r2",
+23
View File
@@ -996,6 +996,26 @@ document, the fields under `version`, where field hooks do not run: the global's
the form without touching the field → a test e-mail still goes out; change the server without typing the
password → the save is refused with "Enter the password again…".
## The mail service's token and its public route (`mail.relay`)
A site that sends through the Intecion Notifications Webservice ([email.md](./email.md)) holds one secret: its own
token. What protects it, and what the new public route can and cannot do:
| | |
|---|---|
| **No key in the package** | The plugin carries the service's address and nothing else. A site gets its token by proving it is served at its host: it makes a nonce, the service calls `POST https://<host>/api/iapl/mail-relay/confirm` with the nonce and a token, and only an answer that hashes both makes the token valid |
| **Where the token is** | `payload-kv`, key `iapl:mail-relay`. The collection refuses every operation through access control (`read`, `create`, `update`, `delete` are `false`) and is hidden: REST, GraphQL and the panel cannot reach it — an admin included (test: `test/mailRelayHttp.test.ts`). Server code with the Local API can, like `smtpPassword`. It is stored as it is (no encryption at rest), never logged, never sent to a browser, never part of a route's answer |
| **A token read from a database dump** | does not work from another server: the service accepts a token only from the addresses the site enrolled from (IPv6: the same `/64`) and answers anything else "enrol again" — which needs the call-back to the real site. It cannot send as another site, and the limits below apply |
| **What a token can do at most** | send within the site's limits (30 an hour, 200 a day, 10 recipients, 10 MB by default) from the service's fixed address, under a sender name the service checks, with `X-Intecion-Site: <host>` on every mail. It cannot set `From`, `Return-Path` or any header, and cannot address a security alert |
| **The confirm route** | public by design, `404` with an empty body unless the body carries a nonce **this site** made in the last 5 minutes (kept as a hash, compared in constant time, single use). It stores the delivered token **beside** the one in use and never replaces a working token: a token becomes the one in use only after the service has accepted it. Rate-limited per address (10 a minute, `mail.relay.confirmRateLimit`). A stranger who calls it learns nothing and changes nothing |
| **Who can start an enrolment** | the server itself (a send without a token) and an admin ("Connect again"). The three state routes need the `admin` role and answer with states only |
| **A site taken over by an attacker with admin rights** | can send mail through the service under any sender name the service's check lets through, within the limits — as it could through the site's SMTP server. Intecion sees the host on every mail and can suspend the site (`relay-suspended`) |
| **Visitors** | cannot reach the service: only the server calls it. What a visitor can trigger is a form's mail (rate limit, Turnstile) and "forgot password" — limited by the site per address and per visitor (`mail.relay.accountMail`), because the service does not limit account mail per address |
| **A subject or name typed by a visitor** | line breaks, control characters, direction marks and other invisible characters are removed before the message leaves (`cleanSubject`); recipients are reduced to bare addresses; a message has no header field |
Turn off: `iapl({ mail: { relay: false } })` — no route, no outbound call, no token. Give the token up:
"Disconnect" in the panel (`disconnectRelay`), which revokes it on the service at once.
## Dashboard alerts by role (`dashboardAlerts`)
The plugin's dashboard alerts read data that only some roles may read (with access control off, on the server),
@@ -1015,6 +1035,9 @@ the full text, as before. The components take the same as props
`ownOrigins` are exported. **Verify count:** `verifyLimit: { store: 'memory' }`; `buildVerifyLimit`,
`verifyLimitKey`, `clearVerifyLimits` (tests) are exported.
- **Dashboard alerts:** `dashboardAlerts: { integrations, cookies }`.
- **The mail service:** `mail: { relay: false }`; `mail.relay: { enrol: 'manual' | false, token, accountMail,
confirmRateLimit }`; `relayConfirmEndpoint`, `enrolRelay`, `disconnectRelay`, `rotateRelayToken`, `setRelayToken`
are exported ([email.md](./email.md)).
- **Verify limit:** `twoFactor.verifyLimit: { max, windowMinutes }`, or `false`.
- **`back` link check of the 2FA screens:** `twoFactor.safeBack: false`, or a function as your own rule;
`safeAdminBack`, `wrapTotpViews`, `copyViews`, `changedViewKeys`, `SAFE_TOTP_VIEW`, `SafeTotpView` are exported.