Skip to content

Fix EmailFormProcessor ignoring block settings#20

Merged
ericof merged 2 commits into
mainfrom
issue-19
Jul 7, 2026
Merged

Fix EmailFormProcessor ignoring block settings#20
ericof merged 2 commits into
mainfrom
issue-19

Conversation

@ericof

@ericof ericof commented Jul 6, 2026

Copy link
Copy Markdown
Member

What

Fixes the EmailFormProcessor silently ignoring the form block's configured
settings, and moves the mail-template storage to a JSONField so template
selection works end to end.

The processor read several block fields under the wrong keys — most visibly
email_template instead of mail_template — so the selected mail template,
admin info, mail header/footer and sender/recipient addresses were dropped and
the defaults used instead.

Changes

Fix + refactor (0d24af5)

  • Type the block payload (SchemaFormBlock) and the submission context, so a
    wrong key is visible rather than silently defaulted.
  • Extract the email helpers (substitute_variables, format_property,
    addresses_from_block, template lookup, mailhost check) into utils.email;
    the processor delegates to them.
  • Resolve sender/recipient/bcc addresses once, up front, and pass them through
    the submission context.
  • Move the mail-templates registry setting to a JSONField
    (schemaform.mail_templates_json), deprecating schemaform.mail_templates,
    with an upgrade step (profile 10001001) migrating existing templates.
  • Add unit tests for the utils.email helpers.

Testing profile (74fd676)

  • Replace the imperative registry setup in the test layer with a declarative
    plone.formblock.testing:testing GenericSetup profile that configures the
    mail settings and installs the captcha add-ons (norobots, hcaptcha,
    recaptcha). Captcha vocabulary test updated for the now-available norobots
    adapter.

Testing

  • make test — full backend suite green (146 passed).
  • ruff check / ruff format clean.

Related issue

Refs #19

Note: the httpHeaders portion of #19 is a frontend concern and is tracked
separately, so this PR does not close the issue.

ericof added 2 commits July 6, 2026 16:50
The processor read block fields under the wrong keys (e.g. `email_template`
instead of `mail_template`), so the selected mail template, admin info,
header/footer and sender/recipient addresses were silently dropped and the
defaults used instead.

- Type the block payload (`SchemaFormBlock`) and the submission context so a
  wrong key is visible rather than silently defaulted.
- Extract the email helpers (`substitute_variables`, `format_property`,
  `addresses_from_block`, template lookup, mailhost check) into `utils.email`;
  the processor now delegates to them.
- Resolve sender/recipient/bcc addresses once, up front, and pass them through
  the submission context.
- Move the mail templates registry setting to a JSONField
  (`schemaform.mail_templates_json`), deprecating `schemaform.mail_templates`,
  with an upgrade step (profile 1000 -> 1001) migrating existing templates.
- Add unit tests for the `utils.email` helpers.

Refs #19
Replace the imperative registry setup in the test layer with a declarative
`plone.formblock.testing:testing` profile that configures the mail settings and
installs the captcha add-ons (norobots, hcaptcha, recaptcha). Update the captcha
vocabulary test for the now-available norobots adapter.
@ericof ericof requested a review from pbauer July 6, 2026 19:55

@pbauer pbauer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works fine now. Thanks!

@ericof ericof merged commit 796ef5a into main Jul 7, 2026
20 checks passed
@ericof ericof deleted the issue-19 branch July 7, 2026 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants