Repository navigation
fix(mail): trim recipients when sending emails separately (#754) - #869
Merged
bmfmancini merged 1 commit intoNov 6, 2026
Merged
Conversation
With "Send Emails Separately" enabled, thold_mail() split the recipient
list on commas without trimming. Lists are commonly joined with ", ", so
every address after the first (" noc@example.org") failed
FILTER_VALIDATE_EMAIL and was skipped without any log entry. A trailing
comma produced an empty entry, and since filter_var('') returns false
and false == '' in PHP, mailer() was even called with an empty address.
Trim each address and drop empty entries, and log any address that is
still invalid instead of skipping it silently.
|
somethingwithproof
approved these changes
Nov 6, 2026
somethingwithproof
left a comment
Member
There was a problem hiding this comment.
No blockers found. The full suite passes on Linux/PHP 8.4; PHP 8.2–8.4 CI is green.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
With Send Emails Separately enabled,
thold_mail()split the recipient list on commas without trimming:Lists are commonly written with
,, so every address after the first (" noc@example.org") failedFILTER_VALIDATE_EMAILand was skipped, with no log entry. A trailing comma produced an empty entry. Sincefilter_var('')returnsfalseandfalse == ''in PHP,mailer()was even called with an empty address.This PR trims each address, drops empty entries, and logs any address that's still invalid instead of skipping it silently.
This is one of two causes of #754. The other, failed sends not logged in the default mode, is a separate PR.
Related Issue
Part of #754.
Motivation and Context
In send-separately mode, only the first recipient on a typical list ever receives threshold mail.
How Has This Been Tested?
Unit tests (Pest): a new
TholdMailSeparateRecipientsTestcovers addresses after,and trailing commas, and an invalid address being logged. Both tests fail without the change.Real poller: Cacti 1.2.32, PHP 8.4, cactid every 60 s, with this exact commit deployed. Send Emails Separately was enabled, and a live threshold was breached with
notify_extra = "a@…, b@…"(two local addresses). The setting was restored afterwards.Types of changes
Checklist: