#111723Restrict email recipients
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.
TransportFactorywraps 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;
MailProfileResolverignores 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
-
Gerrit Code Review pushed patch set 1 for main to change 98339 status
NewUnder Review 12/04/26, 14:39