Issue Feature Under Review

#111723Restrict email recipients

Josua Vogel 12/04/26, 14:35 updated 12/04/26, 14:39

Description

Problem

Staging installations usually run with a copy of production data. Emails sent while testing (form finishers, password recovery, notifications, extensions using the Mailer API) can therefore reach real customers, editors or form submitters.

The core offers no setting for this today.

Proposal

A new setting $GLOBALS['TYPO3_CONF_VARS']['MAIL']['allowedRecipients'], empty by default: a comma-separated list of single addresses (editor@example.org) and domains starting with an at sign (@example.org), matched case-insensitively.

$GLOBALS['TYPO3_CONF_VARS']['MAIL']['allowedRecipients'] = '@agency.example, @customer.example';

Behaviour

  • Emails are delivered to allowed recipients only. Every other recipient is skipped and logged as a warning.
  • An email without any allowed recipient is not sent at all and logged; the caller does not receive an exception.
  • Only the SMTP envelope is reduced. The message headers (To, Cc) stay unchanged, so an allowed tester sees exactly what was sent.
  • TransportFactory wraps every real transport when the setting is used. Spools are not wrapped; the restriction applies when the spool is flushed, so already spooled emails are covered too.
  • The setting applies to every mail profile; MailProfileResolver ignores it inside a profile, so a profile cannot widen it.
  • Without the setting nothing changes.

Out of scope

Emails sent without the TYPO3 mail API (PHP mail(), self-built Symfony transports) are not covered; staging installations should still block outgoing mail on the network level.

Reviews 1

History 01

  1. Gerrit Code Review pushed patch set 1 for main to change 98339 status New Under Review 12/04/26, 14:39