Mail relay: state block without an import-map entry, e2e on the reference site, sharper failure reports
- the state block is rendered by IntegrationStatusBanner (no new admin component: generate:importmap gives no diff) - reference site: e2e/mail-relay.spec.ts with a fixture and setup script; e2e:built runs it with both bundlers - a failed enrolment is reported as what it was; the service's own refusal after a fresh enrolment - a message keeps its key after any failure that is not final - a local site is shown as refused in the panel before any e-mail Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
dd3792cbc7
commit
2cceceffd0
@@ -97,7 +97,23 @@ 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 }` |
|
||||
| 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 |
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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`;
|
||||
|
||||
@@ -552,6 +552,34 @@ 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) — 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. **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):
|
||||
|
||||
Reference in New Issue
Block a user