E-mail: "Sending method" is an explicit choice - IWSN (built-in), Own SMTP server, Microsoft Graph (deprecated)

What is chosen is what is used. The choice is the stored field `emailMethod` of Site integrations (empty until
somebody chooses); `emailTransport` of 1.6 - 1.17.0 stays, hidden.

- no silent switch: a chosen method that cannot be used (SMTP incomplete, Graph without GRAPH_*) fails loudly
  - status smtp-incomplete / graph-not-set-up, state block, doctor mail-method - and nothing is sent another way
- upgrade writes nothing and loses no mail: until somebody chooses, the order of 1.17.0 applies and the field
  shows its result as selected; the first save of the panel's form stores the choice
- only the chosen method's fields are shown; the test e-mail names the method (Graph too)
- mail: { relay: false } does not offer "IWSN" (the stored values stay three: one SQL enum for every project)
- Postgres / SQLite: one migration (a column). Before it runs the plugin's readers read the global without the
  field, mail goes the old way, one loud log line and the doctor say what to do
- getMailMethod, setMailMethod, resolveMailMethod, readMailSettings, mailMethodColumnMissing exported
- tests on SQLite, Postgres and MongoDB, with and without the migration; docs, AGENT.md, skills, changelog

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-26 22:39:03 +01:00
co-authored by Claude Fable 5.2
parent c6841a1674
commit ee8ea42956
26 changed files with 376 additions and 138 deletions
+3 -2
View File
@@ -313,8 +313,7 @@ describe('switched off, and what did not change', () => {
const endpoints = (config: SanitizedConfig) => (config.endpoints ?? []).map((e) => `${e.method} ${e.path}`)
const stored = (fields: Field[]): string[] =>
fields.flatMap((f) => {
// (a virtual field has no column and no stored value: "Sending method", whose choice is in the key-value store)
if (f.type === 'ui' || ('virtual' in f && f.virtual)) {return []}
if (f.type === 'ui') {return []}
if (f.type === 'tabs') {return f.tabs.flatMap((t) => stored(t.fields))}
const own = 'name' in f && f.name ? [`${f.name}:${f.type}${f.type === 'select' ? `(${(f.options as { value: string }[]).map((o) => (typeof o === 'string' ? o : o.value)).join('|')})` : ''}`] : []
return 'fields' in f && Array.isArray(f.fields) ? [...own, ...stored(f.fields).map((n) => ('name' in f && f.name ? `${f.name}.${n}` : n))] : own
@@ -341,6 +340,8 @@ describe('switched off, and what did not change', () => {
const on = names(await makeConfig(undefined, 'fieldson'))
expect(on).toEqual(names(await makeConfig({ relay: false }, 'fieldsoff')))
expect(on).toEqual([
// new in 1.17.1 (Postgres / SQLite: one migration); the same three values with the service on and off
'emailMethod:select(relay|smtp|graph)',
'emailTransport:select(smtp|graph)',
'smtpFromAddress:email',
'smtpFromName:text',