IWSN: "Połącz z IWSN" — a person of Intecion connects the site (contract 1.8.0)

- the state block on the e-mail tab (method IWSN): the button while the service offers the confirmation page
  (connectAvailable) or before the site has enrolled; a click asks the site's server for the link
  (POST /api/iapl/mail-relay/connect-link, admin only), which asks the service (POST /v1/connect, enrolling first),
  checks that it begins with the service's own {base}/connect?, and hands it over without storing or logging it;
  the browser opens it in a new tab with noopener noreferrer; the block asks /v1/status every 5 s for 10 min
- states: waiting for confirmation (button), waiting for approval (no page), connected, stopped; 503
  connect-unavailable and 429 said in the admin's language; a load of the panel asks the service while the site waits
- dashboard alert for a waiting site (live); doctor mail-relay-connect (error) — replaces the pending warning and the
  "not enrolled yet" note of mail-relay-state
- opt-out mail.relay.connectButton: false (no button, no route); building blocks requestRelayConnectLink,
  isRelayConnectUrl, RELAY_CONNECT_LINK_PATH; the fake service implements /v1/connect, connectAvailable and
  confirmConnect
- contract copy 1.8.0 (IWDL working tree, checksums match); docs, AGENT.md, setup / upgrade / debug skills, changelog

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-12-01 21:42:23 +01:00
co-authored by Claude Opus 5.5
parent 347e3bafa1
commit 2c0262367d
41 changed files with 1113 additions and 57 deletions
+29
View File
@@ -14,6 +14,35 @@ once there are more than 20.
This heading and the 1.17.2 section below (never released on its own) become one 1.18.0 entry at release. Read every
"what changes for an existing site" list: the one here and the one in each subsection.
### IWSN: "Połącz z IWSN" — a person of Intecion connects the site (docs/email.md, contract 1.8.0)
> **What changes for an existing site:** nothing for a site whose "Sending method" is SMTP or Microsoft Graph, and
> nothing for a site already active on IWSN. A site on IWSN that is new or still waits now shows **"Połącz z IWSN"**
> on Site integrations → E-mail sending: pressing it opens the service's confirmation page in a new tab, where a
> person of Intecion signs in with an `@intecion.com` address and presses "Potwierdź"; the panel then shows
> "Connected to IWSN" by itself. Until then the site's e-mails are refused (`relay-pending`), the dashboard alert says
> so, and `iapl-doctor --deep` reports an **error** (`mail-relay-connect`). No schema change, no import-map change.
- **The button** (state block on the e-mail tab, method IWSN): shown while the service offers the confirmation page
(`connectAvailable` in `/v1/status`) or before the site has enrolled. A click asks the site's server for the link
(`POST /api/iapl/mail-relay/connect-link`, admin only, enrolling first when there is no token); the server asks the
service (`POST /v1/connect`), checks that the link begins with the service's own `{base}/connect?`, and hands it
over without storing or logging it; the browser opens it with `noopener noreferrer`. The panel then asks
`/v1/status` every 5 seconds for at most 10 minutes; every load of the panel asks too while the site waits.
- **States shown:** "Waiting for confirmation" (with the button), "waiting for approval" (no button: no confirmation
page), "Connected to IWSN", stopped. "The confirmation page is not available now" for `503 connect-unavailable`; a
wait in minutes for more than 10 links an hour.
- **Dashboard alert** for a waiting site (live, no call to the service); the text of `relay-pending` now speaks of
confirmation.
- **Doctor:** `mail-relay-connect` (error, deep) — the method is IWSN and the site is not connected or not confirmed.
`mail-relay-state` no longer reports "waiting for approval" (warning) or "not enrolled yet" (info): both are this error.
- **Opt-out:** `mail: { relay: { connectButton: false } }` — no button, no route.
- **Building blocks:** `requestRelayConnectLink(payload, options?)` (`ConnectLinkResult`), `isRelayConnectUrl(url, base)`,
`RELAY_CONNECT_LINK_PATH`, `RelayStatus.connectAvailable`; `relayPanelEndpoints(own, { connectLink })`. The stand-in:
`createFakeRelay({ connect: 'available' | 'unavailable' })`, `relay.confirmConnect(connectUrl)`, `connectAvailable` in
its `/v1/status`, `/v1/connect`.
- The contract copy is 1.8.0 (`RELAY_CONTRACT_VERSION`); additive, every other route unchanged.
### Two-step verification: the first set-up is confirmed by e-mail (docs/security.md)
> **Read before upgrading — what changes for an existing site, most important first:**
+8 -2
View File
@@ -1363,8 +1363,12 @@ reports `mail-method` info (nothing picked yet) or nothing (picked and usable).
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. Nothing to arrange with Intecion: a site that passes the call-back is active at once (`relay-pending`, held for
approval, is the exception — the panel says so).
5. **A person of Intecion connects the site** (contract 1.8.0): after its first e-mail (or the button) the site waits
(`relay-pending`). Site integrations → E-mail sending → **"Połącz z IWSN"** opens the service's confirmation page in a
new tab; a person of Intecion signs in with an `@intecion.com` address and presses "Potwierdź"; the block shows
"Connected to IWSN" by itself (it asks every 5 s for 10 min, and on every load while the site waits). Tell the owner
that step is theirs. Nothing to paste, no token. Opt-out: `mail: { relay: { connectButton: false } }` (no button, no
route). **Verify:** `iapl-doctor --deep` has no `mail-relay-connect` error; a test e-mail answers "through IWSN".
6. **Launch needs nobody:** a site enrolled on its development address and then served on the real domain (or moved
to another domain) enrols by itself on its first e-mail. **A non-public copy does not send by itself:** a site
whose host matches `iapl({ developmentHosts })` — default `['*.dev.netscale.pl']`, Intecion's development
@@ -1414,6 +1418,7 @@ overrides per adapter; `resolveRelayOptions` reads what is in effect):
| `otherHosts` | `'auto'` | a database holding another host's connection: a public site enrols by itself (launch, a move), a non-public one (`IAPL_NOINDEX=1` / `developmentHosts`) neither enrols nor sends until "Connect again"; a list of the site's own other hosts; `'wait'` (a public site without a connection waits too); `'enrol'` (no rule) |
| `developmentHosts` | `iapl({ developmentHosts })`, default `DEFAULT_DEVELOPMENT_HOSTS` = `['*.dev.netscale.pl']` (`pluginDevelopmentHosts`) | host patterns (`*`) of development and staging addresses, for the mail service alone: a site there is non-public for `otherHosts` with no env (`siteIsNonPublic`, `siteNonPublicSignal` → `NonPublicSignal`, `matchDevelopmentHost`, `isDevelopmentHost`); `[]` = none. Checked when the config is built (`assertDevelopmentHosts`): not an array of non-empty host patterns, or a lone `*` → the site does not start; Unicode patterns are punycoded, a trailing dot and the port are ignored |
| `enrol` | `'auto'` | `'manual'` (only "Connect again" / `enrolRelay`), `false` (token from `token` / `setRelayToken`) |
| `connectButton` | `true` | `false`: no "Połącz z IWSN" and no `POST /api/iapl/mail-relay/connect-link`; confirm by an operator or with `requestRelayConnectLink` |
| `accessKeyField` | `false` | `true`: admins get "Enter an access key" in the state block (a hand-issued token) |
| `token` | — | a token from elsewhere; nothing is stored, the site does not enrol |
| `senderName` | panel → site name (`relaySenderName`) | fixed name or function |
@@ -1447,6 +1452,7 @@ needs more: Intecion raises the limits, or SMTP.
|---|---|
| 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` |
| A button of your own for the confirmation by Intecion | `requestRelayConnectLink(payload)` (`ConnectLinkResult`: `{ state: 'pending', connectUrl, expiresAt }` / `{ state: 'active' }` / a refusal) on a person's click only; open `connectUrl` in a new tab with `noopener noreferrer`; never store, log or fetch it; `isRelayConnectUrl(url, base)`; the route `RELAY_CONNECT_LINK_PATH`; the stand-in `createFakeRelay({ connect })` + `relay.confirmConnect(url)` |
| 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` |
+1 -1
View File
@@ -122,7 +122,7 @@ through this procedure. Ask only when you are missing something you cannot get y
| a site sends nothing: "The data comes from another site (…), so this copy does not send e-mails by itself" / `relay-refused`, cause `client-other-host` | the site is non-public — its host matches `developmentHosts` (built in: `*.dev.netscale.pl`) or `IAPL_NOINDEX=1` is set; `iapl-doctor --deep` says which (`mail-non-public`) — and its database holds another host's connection: a staging copy of production, or production's data copied back onto the development address. Expected — a copy with production's data must not mail real people by itself | should it send: "Connect again" in the state block, once (until the data is replaced). A copy that must never send: `mail: { relay: false }` or SMTP to a catcher. **The production site itself says this:** `IAPL_NOINDEX` was left set after launch — remove it; or its host matches a development pattern — take it out of `iapl({ developmentHosts })` |
| the site does not start: "[iapl] … developmentHosts must be an array of host patterns …" | the list is not an array of non-empty host patterns (a single string, `null`, `['']`), or holds a lone `*` | write it as `['*.dev.netscale.pl', 'staging.client.pl']`; `[]` = none; to change who waits use `mail.relay.otherHosts` |
| a staging or test copy **does** send, to real addresses | its host matches no development pattern and it has no `IAPL_NOINDEX=1`, so it looks like a launch (a public site enrols by itself); the doctor's deep run notes "the database also holds the mail-service connection of another host" | name its host in `iapl({ developmentHosts: ['*.dev.netscale.pl', '<the copy's pattern>'] })`, or `IAPL_NOINDEX=1` on the copy; to be sure: `mail: { relay: false }` or SMTP to a catcher |
| `relay-pending` / "waiting for approval" | while the service runs with enrolment "pending" (from its launch until Intecion switches to open enrolment), every new site waits for approval; after that, the exception (many new sites at once, or approval by hand) | Intecion approves it on the service; nothing to change on the site; the same token then works |
| `relay-pending` / "Waiting for confirmation" / doctor `mail-relay-connect` | a new site waits until a person of Intecion confirms it (contract 1.8.0) | Site integrations → E-mail sending → "Połącz z IWSN"; the person signs in with an @intecion.com address on the page that opens and presses "Potwierdź"; the block turns "Connected" by itself. "Waiting for approval" with no button, or "the confirmation page is not available": Intecion confirms the host by hand. "Too many confirmation links": wait the minutes it says. The same token works afterwards |
| `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 |
+1 -1
View File
@@ -669,7 +669,7 @@ scaling (5). `●` routes for pages need the database at build time (PROGRAMISTA
6. **Notifications**: form messages in every language.
7. **Site integrations → E-mail sending**: "Sender name" (the client's name; empty = the site name) and **"Sender
address"** (the client's address: with the mail service replies go there). "Sending method" stays **IWSN (built-in)**; choose **Own SMTP server** and fill in its fields **only** when the client asked
for its own server — what is chosen is what is used, an incomplete SMTP server sends nothing. A new site sends through IWSN with nothing picked; picking another option and saving stores it (the panel warns before the save when its settings are incomplete). On the production domain: the block "How e-mails are sent" must say "Connected to IWSN" ("waiting for approval": while the service runs with enrolment "pending" (from its launch until Intecion switches to open enrolment), every new site waits for approval — ask Intecion to approve the host; under open enrolment it is the exception; the real domain enrols by itself at launch although the site was connected on its development address — nothing to press; "The data comes from another site" = the site is non-public (its host matches `developmentHosts`, built in `*.dev.netscale.pl`, or `IAPL_NOINDEX=1`) and holds a copy of another site's data: press "Connect again" only if the copy should send — on the production domain it means `IAPL_NOINDEX` was left set. A development address under `*.dev.netscale.pl` needs nothing; a staging or test copy on any other host must have its host in `iapl({ developmentHosts: […] })` (an array of host patterns: a single string, an empty entry or a lone `*` stops the start) or `IAPL_NOINDEX=1`, or it mails the real addresses in its data), then **Send test e-mail** → "through IWSN". Turnstile (for testing site
for its own server — what is chosen is what is used, an incomplete SMTP server sends nothing. A new site sends through IWSN with nothing picked; picking another option and saving stores it (the panel warns before the save when its settings are incomplete). On the production domain: the block "How e-mails are sent" must say "Connected to IWSN" ("Waiting for confirmation": press "Połącz z IWSN" and have a person of Intecion confirm the site on the page that opens — the owner's step, @intecion.com sign-in; "waiting for approval" with no button: ask Intecion; the real domain enrols by itself at launch although the site was connected on its development address — nothing to press; "The data comes from another site" = the site is non-public (its host matches `developmentHosts`, built in `*.dev.netscale.pl`, or `IAPL_NOINDEX=1`) and holds a copy of another site's data: press "Connect again" only if the copy should send — on the production domain it means `IAPL_NOINDEX` was left set. A development address under `*.dev.netscale.pl` needs nothing; a staging or test copy on any other host must have its host in `iapl({ developmentHosts: […] })` (an array of host patterns: a single string, an empty entry or a lone `*` stops the start) or `IAPL_NOINDEX=1`, or it mails the real addresses in its data), then **Send test e-mail** → "through IWSN". Turnstile (for testing site
`1x00000000000000000000AA`, secret `1x0000000000000000000000000000000AA`; production keys from the client), analytics/pixel
IDs, IndexNow → generate key. Mail/Turnstile errors show up as a dashboard alert.
8. **Forms**: check the addresses in the Emails tab of the seeded forms.
+11 -2
View File
@@ -714,7 +714,7 @@ PROGRAMISTA §6, items 73–75; email.md; AGENT.md §7.2) — nothing to run; re
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); the client's
processing agreement names the service. Tell Intecion the host: while the service runs with enrolment "pending" (from its launch until Intecion switches to open enrolment), every new site waits for approval (the panel says "waiting for approval"); under open enrolment a site is active as soon as it enrols.
processing agreement names the service. A new site waits until a person of Intecion confirms it: "Połącz z IWSN" in the panel (contract 1.8.0).
**Launch and a domain move need nothing:** the real domain enrols by itself although the database holds the
development address's connection. **A staging or test copy of the database** neither enrols nor sends by itself
**when it is non-public**: its host matches `iapl({ developmentHosts })` — built in `*.dev.netscale.pl`, so the
@@ -736,7 +736,16 @@ PROGRAMISTA §6, items 73–75; email.md; AGENT.md §7.2) — nothing to run; re
**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 is live at
`https://webservices.intecion.net/mail`; while the service runs with enrolment "pending" (from its launch until Intecion switches to open enrolment), every new site waits for approval — keep SMTP until it is approved, or `relay: false`.**
`https://webservices.intecion.net/mail`; a new site waits until a person of Intecion confirms it ("Połącz z IWSN") — keep SMTP until then, or `relay: false`.**
**→ 1.18.0, IWSN is connected by a person of Intecion (CHANGELOG "Unreleased (for 1.18.0)" → "IWSN: Połącz z IWSN"; email.md "The mail service"; AGENT.md §7.2 point 5) — nothing to run:**
1. No schema change, no migration, no import-map change. Sites whose "Sending method" is SMTP or Microsoft Graph see no
change at all.
2. A site on IWSN that is already active stays active. A site that waits (`relay-pending`, or doctor `mail-relay-connect`
error after the upgrade): Site integrations → E-mail sending → **"Połącz z IWSN"** → a person of Intecion confirms
it on the page that opens (an @intecion.com sign-in — the owner's step, tell them) → the block says "Connected to
IWSN" by itself. Then send a test e-mail.
3. A project that does not want the button: `mail: { relay: { connectButton: false } }` (no button, no route).
**→ 1.17.1, e-mail (CHANGELOG 1.17.1 point 5; PROGRAMISTA §6, item 82; email.md "Which transport a send takes"; AGENT.md §7.2) — nothing to run, one check:**
1. **MongoDB: no migration. Postgres / SQLite: `pnpm payload migrate:create`** (the new field `emailMethod` is a column),
+2 -1
View File
@@ -131,7 +131,8 @@ Turn off: `iapl({ doctor: false })`. Adapt: `iapl({ doctor: { tokenVar: 'MY_TOKE
| mail | `mail-method` | error / info | (deep) the chosen "Sending method" can be used — "Own SMTP server" with server, user name and password, "Microsoft Graph" with the `GRAPH_*` variables; otherwise e-mails are not sent and nothing is sent another way (error). On Postgres / SQLite: the column of `emailMethod` exists — the 1.17.1 migration has run (error). Nobody has chosen yet: the site picks a method from what is filled in until Site integrations is saved (info) |
| | `mail-transport` | error / warning | (deep) an e-mail transport is in effect (not: the mail service switched off and no SMTP server); the last sends worked — failing: warning, error once it has lasted 24 hours |
| | `mail-non-public` | info | (deep) on the mail service: says which signal makes the site a non-public copy — its host matches a development pattern (`developmentHosts`, named in the finding) or `IAPL_NOINDEX` is set — and what to change if the site is in fact the public one |
| | `mail-relay-state` | error / warning / info | (deep) on the Intecion mail service: not disconnected and not stopped (error), not waiting for approval, not refused at enrolment, not a non-public copy of another site's database that waits for "Connect again" (`client-other-host`), the sender name not replaced (warning); not enrolled yet, and a public site whose database also holds another host's connection — its own past after a launch or a move, or a copy that forgot `IAPL_NOINDEX=1` (info) |
| | `mail-relay-connect` | error | (deep) the sending method is IWSN and the site is connected and confirmed — not "not enrolled yet", not waiting for confirmation by Intecion (contract 1.8.0). The fix names "Połącz z IWSN", or Intecion when the service offers no confirmation page |
| | `mail-relay-state` | error / warning / info | (deep) on the Intecion mail service: not disconnected and not stopped (error), not refused at enrolment, not a non-public copy of another site's database that waits for "Connect again" (`client-other-host`), the sender name not replaced (warning); a public site whose database also holds another host's connection — its own past after a launch or a move, or a copy that forgot `IAPL_NOINDEX=1` (info) |
| | `mail-reply-address` | warning | (deep) on the mail service, "Sender address" is filled in: replies go there |
| | `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` |
+36 -12
View File
@@ -136,10 +136,28 @@ What the site needs for it:
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 site that passes the call-back is active at once.** Waiting for approval is the exception: the service
holds a new site back when many new sites appear at once (more than a few a day from one address or domain, or
more than its daily number in all), or when Intecion has set it to approve by hand. Mail is then not sent until
Intecion approves the site; the same token works afterwards, and the panel says so.
- **A new site is connected by a person of Intecion** (contract 1.8.0 §2.1, the service's `connect` policy). It
enrols as before, then **waits** (`pending`): its mail is refused with `site-pending` (status `relay-pending`), not
sent and not kept. On Site integrations → E-mail sending, with "IWSN (built-in)" as the method, an administrator
presses **"Połącz z IWSN"** ("Connect to IWSN"). The site's **server** asks the service for a link
(`POST /v1/connect`) and the panel opens it **in a new tab** (`noopener noreferrer`). A person of Intecion signs
in there with an `@intecion.com` address (Cloudflare Access) and presses "Potwierdź". The panel asks the service
every 5 seconds for at most 10 minutes and shows "Connected to IWSN" by itself; every load of the panel asks too
while the site waits. Mail sent after that leaves; mail refused before it is not sent again.
- The link is valid 15 minutes, for one confirmation; each press makes a new one. It is opened only when it begins
with the service's own `{base}/connect?` (the plugin checks it on the server and in the browser), and it is
never stored, logged or fetched by the server.
- What the block says: **"Waiting for confirmation"** with the button (the service offers the page:
`connectAvailable`); **"waiting for approval"** with no button (no confirmation page — an operator confirms the
site); **"Connected to IWSN"**; **stopped** (suspended). A site that has not enrolled yet shows the button too:
pressing it enrols first.
- When the service has no confirmation page right now (`503 connect-unavailable`) the panel says "ask your
administrator to have the site confirmed"; more than 10 links an hour (`429`) says when to try again.
- The dashboard alert shows a waiting site; `iapl-doctor --deep` reports it as an **error** (`mail-relay-connect`).
- No token or paste field is involved. Sites on SMTP or Microsoft Graph see nothing of this.
- **Opt-out:** `mail: { relay: { connectButton: false } }` — no button and no route; the site is then confirmed by
an operator, or by the project's own button with `requestRelayConnectLink(payload)` (open the answered
`connectUrl` in a new tab; `isRelayConnectUrl(url, base)` checks it).
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
@@ -392,18 +410,19 @@ await runWithMailKind('account', () => sendWelcomeMails(payload, user))
Site integrations → E-mail sending starts with "How e-mails are sent" (component `MailRelayStatus` from `/admin`,
rendered by the tab's status banner — **no import-map entry of its own, so nothing to regenerate**): 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
transport in effect; for the mail service the state (connected, waiting for confirmation — with "Połącz z IWSN" —,
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** — and **Enter an access key** only
with `mail.relay.accessKeyField: true` ("The token" above).
Routes (all three need the `admin` role: not logged in → 401, other role → 403; none ever answers with a token):
Routes (all four 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 — only with `accessKeyField: true`, otherwise `403` |
| `POST /api/iapl/mail-relay/disconnect` | give the token up |
| `POST /api/iapl/mail-relay/connect-link` | "Połącz z IWSN": asks the service for the confirmation link (`POST /v1/connect`, enrolling first when there is no token) and answers it as `connectUrl` + `expiresAt`, `Cache-Control: no-store`; nothing is stored. Absent with `connectButton: false` (`RELAY_CONNECT_LINK_PATH`) |
| `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; **refused** calls are rate-limited (10 a minute per address, `mail.relay.confirmRateLimit`) — a call that carries the nonce is never turned away by the limit, so junk from the same address cannot keep the site from enrolling |
These are the first routes under `/api/iapl/`; the others stay under `/api/ipal/` until 2.0. The confirm path is
@@ -419,7 +438,7 @@ the service), each with a text in the editor's language:
| Code | Meaning | What to do |
|---|---|---|
| `relay-pending` | enrolled, but held for approval by Intecion — the rule while the service runs with enrolment "pending" (from its launch until Intecion switches to open enrolment), every new site waits for approval; after that the exception (many new sites at once, or approval by hand) | Intecion approves the host; nothing to do on the site |
| `relay-pending` | enrolled, waiting for confirmation by a person of Intecion (contract 1.8.0) | "Połącz z IWSN" in the panel and the confirmation on the page that opens; without the button (no confirmation page), Intecion confirms the host |
| `relay-suspended` | stopped by Intecion | contact Intecion; SMTP in the panel sends meanwhile |
| `relay-refused` | the site could not enrol; or a token issued by hand stopped working (new server address, token no longer valid) | "When the site cannot be confirmed" below; hand-issued: ask Intecion for the address to be added or for a new token |
| `relay-disconnected` | an admin pressed "Disconnect" | "Connect again", or fill in SMTP |
@@ -464,6 +483,7 @@ message); "Connect again" asks at once. Other causes: `host-not-allowed` (not a
| `otherHosts` | `'auto'` | a database that holds another host's connection. `'auto'`: a public site enrols by itself (launch, a domain move); a non-public one (`IAPL_NOINDEX=1` or `developmentHosts`) neither enrols nor sends until "Connect again". A list = those hosts are this site's own. `'wait'` = a public site without a connection of its own waits too. `'enrol'` = no rule |
| `developmentHosts` | the plugin's list: `iapl({ developmentHosts })`, default `['*.dev.netscale.pl']` (`pluginDevelopmentHosts(payload)`) | host patterns (`*` = any characters) of development, staging and preview addresses, for the mail service alone: a site on such a host is non-public for `otherHosts`, like one with `IAPL_NOINDEX=1`, with no environment variable (`siteIsNonPublic`, `siteNonPublicSignal`, `matchDevelopmentHost`, `isDevelopmentHost`). `[]` = none |
| `enrol` | `'auto'` | `'manual'`: only "Connect again" or `enrolRelay()` enrols. `false`: never (the token comes from `token` or `setRelayToken`) |
| `connectButton` | `true` | `false`: no "Połącz z IWSN" in the state block and no `connect-link` route; the site is confirmed by an operator or by the project's own code (`requestRelayConnectLink`) |
| `accessKeyField` | `false` | `true` shows "Enter an access key" in the state block and lets its route store a hand-issued token an admin pastes |
| `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 |
@@ -516,7 +536,9 @@ await payload.sendEmail({ to: '[email protected]', 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)`,
- `allow` / `relay.allow(host)`: hosts that are active at once; others wait (`pending`). `connect: 'unavailable'` makes
`/v1/connect` answer `503 connect-unavailable`; `relay.confirmConnect(connectUrl)` stands in for the person who
confirms a link (true when it was the site's current one, not expired). `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>`).
@@ -647,7 +669,8 @@ Works on any `text` field. After wiring it in a project you may need
To the mail service (when the owner says so):
1. Upgrade; check that `serverURL` is the site's public address.
2. Tell Intecion the host: while the service runs with enrolment "pending" (from its launch until Intecion switches to open enrolment), every new site waits for approval; the panel says so. Under open enrolment the site is active as soon as it enrols.
2. After the first e-mail the site waits for confirmation: press "Połącz z IWSN" in Site integrations → E-mail
sending and have a person of Intecion confirm it on the page that opens (keep Graph until then).
3. Site integrations → E-mail sending → "Sending method": choose **IWSN (built-in)** and save. Then remove the four
`GRAPH_*` variables in Coolify and redeploy.
4. Site integrations → E-mail sending → send a test e-mail: the answer says "through IWSN".
@@ -829,8 +852,9 @@ 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`,
`iapl-doctor` ([doctor.md](./doctor.md)): `mail-transport` (nothing set up; sending is failing), `mail-relay-connect`
(error: the method is IWSN and the site is not connected or not confirmed), `mail-relay-state` (stopped, refused,
disconnected, a held copy, 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).