Mail relay: contract 1.6.0, the token tied to its host, IWSN in the panel

- contracts/mail-relay refreshed from IWDL 83af8c6 (1.6.0)
- an answer that is not the service's JSON is 'not confirmed' unless its status is 400 to 499
- a site with a token issued by hand does not enrol to heal: it stops and says what to ask Intecion for
- a store made on another host (a database copied to staging) is not used: the copy enrols as itself, nothing is revoked
- the panel calls the service IWSN (RELAY_SHORT_NAME); docs, logs and the doctor keep the full name

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-25 21:51:47 +01:00
co-authored by Claude Fable 5.2
parent 7d766b6d58
commit 0ee74ab2a4
36 changed files with 380 additions and 128 deletions
@@ -101,6 +101,8 @@ through this procedure. Ask only when you are missing something you cannot get y
| 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-refused` on a site whose token was entered by hand ("does not know the server this site now runs on" / "access key … no longer valid") | the site moved or got a second server, or its token expired; a site with a hand-issued token cannot enrol by itself | Intecion adds the server's address, or issues a new token (state block → "Enter an access key") |
| staging sends nothing after its database was copied from production: "Not connected yet" / "waiting for approval" | expected: production's token is tied to production's host and is not used on the copy; the copy enrolled as itself | Intecion approves the staging host, or staging uses SMTP / `mail: { relay: false }` |
| `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 |
@@ -22,7 +22,7 @@ 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),
with the Intecion mail service (IWSN in the panel): 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
+1 -1
View File
@@ -109,7 +109,7 @@ 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
The mail service (the default transport) (IWSN in the panel): 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
+2 -4
View File
@@ -43,7 +43,7 @@ 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 works through the built-in Intecion mail service with no
4. Forms: which forms, who receives the submissions? E-mail works through the built-in Intecion mail service (IWSN in the panel) 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?
@@ -646,9 +646,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). 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
for its own server. On the production domain: the block "How e-mails are sent" must say "Connected to IWSN" ("waiting for approval" = ask Intecion to approve the host), 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.
@@ -552,7 +552,7 @@ 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;
**→ 1.17.0, e-mail (the Intecion mail service (IWSN in the panel) is the default transport; Microsoft Graph deprecated; CHANGELOG 1.17.0;
PROGRAMISTA §6, item 73; email.md; AGENT.md §7.2) — nothing to run; read which case the site is:**
1. **Every site:** no schema change, no migration, no import-map change. The e-mail tab gains the block "How e-mails
are sent" and new wording ("Automatic", "Own SMTP server").
+2 -2
View File
@@ -70,7 +70,7 @@ test.describe('the mail service', () => {
await page.fill('#ipal-test-email-to', '[email protected]')
await page.getByRole('button', { name: /Send test e-mail|Wyślij testowy e-mail/ }).click()
// the answer of the test e-mail names the transport and the sender name that was used
await expect(page.getByText(/Test e-mail sent to anna@example\.org through the built-in mail service|Testowy e-mail wysłano na adres anna@example\.org przez wbudowaną usługę pocztową/)).toBeVisible({ timeout: 30_000 })
await expect(page.getByText(/Test e-mail sent to anna@example\.org through IWSN|Testowy e-mail wysłano na adres anna@example\.org przez IWSN/)).toBeVisible({ timeout: 30_000 })
// the service was asked once, called the site's confirm route, and took one message
expect(relay.requests.map((r) => r.path).slice(0, 2)).toEqual(['/v1/enrol', '/v1/send'])
@@ -79,7 +79,7 @@ test.describe('the mail service', () => {
// "Check now" asks the service; the block then says connected and what is left of the hour
await block.getByRole('button', { name: /Check now|Sprawdź teraz/ }).click()
await expect(block).toContainText(/Connected to the built-in mail service|Połączono z wbudowaną usługą pocztową/)
await expect(block).toContainText(/Connected to IWSN|Połączono z IWSN/)
await expect(block).toContainText(/Left this hour: 29|Pozostało w tej godzinie: 29/)
// (Payload takes the login cookie only from the site's own origin, so the request says where it comes from)
+2 -2
View File
@@ -2783,7 +2783,7 @@ export interface SiteIntegration {
checkedAt?: string | null;
};
/**
* Automatic uses your SMTP server when it is filled in below, and the built-in mail service otherwise.
* Automatic uses your SMTP server when it is filled in below, and IWSN otherwise.
*/
emailTransport?: ('smtp' | 'graph') | null;
/**
@@ -2795,7 +2795,7 @@ export interface SiteIntegration {
*/
smtpFromName?: string | null;
/**
* Optional: fill in only to send through your own mail server instead of the built-in mail service.
* Optional: fill in only to send through your own mail server instead of IWSN.
*/
smtpHost?: string | null;
/**