LSaddon::mail: fix handling CC/BCC headers if not provided as array

This commit is contained in:
Benjamin Renard 2024-02-22 19:13:35 +01:00
parent 62759330a8
commit d26c52400e
Signed by: bn8
GPG key ID: 3E2E1CE1907115BC

View file

@ -229,6 +229,7 @@ function sendMail($to, $subject, $msg, $headers=null, $attachments=null,
foreach(array_keys($headers) as $header) { foreach(array_keys($headers) as $header) {
if(in_array(strtoupper($header), array('BCC', 'CC'))) { if(in_array(strtoupper($header), array('BCC', 'CC'))) {
$headers[$header] = ensureIsArray($headers[$header]);
if (isset($MAIL_CATCH_ALL) && $MAIL_CATCH_ALL) { if (isset($MAIL_CATCH_ALL) && $MAIL_CATCH_ALL) {
$logger -> debug("Mail catched: remove $header header"); $logger -> debug("Mail catched: remove $header header");
$msg .= sprintf( $msg .= sprintf(
@ -238,7 +239,8 @@ function sendMail($to, $subject, $msg, $headers=null, $attachments=null,
_("\n%s: %s") _("\n%s: %s")
), ),
strtoupper($header), strtoupper($header),
(is_array($headers[$header])?implode(',', $headers[$header]):$headers[$header])); implode(', ', $headers[$header])
);
unset($headers[$header]); unset($headers[$header]);
continue; continue;
} }