Fold the To list passed to mail()

mailSend() joined the To addresses for mail() with its own implode, so
a long list still went out as one line, while the To header used for
getSentMIMEMessage() and DKIM signing is folded by addrAppend(). mail()
keeps CRLF + space folds in its to argument, so build it with
addrAppend() too.
This commit is contained in:
dualfroz committed 2026-10-04 12:54:41 +02:00
1 parent 95d2378b6a
commit 1ac61eecb6
2 files changed
+39 -1

No files matched your search

+2 -1
View File
@@ -2090,7 +2090,8 @@ class PHPMailer
foreach ($this->to as $toaddr) {
$toArr[] = $this->addrFormat($toaddr);
}
$to = trim(implode(', ', $toArr));
//Fold long lists the same way as the To header, mail() keeps CRLF + WSP folds intact
$to = trim(substr($this->addrAppend('To', $this->to), strlen('To:')));
//If there are no To-addresses (e.g. when sending only to BCC-addresses)
//the following should be added to get a correct DKIM-signature.