Normalise line breaks in S/MIME signed messages

openssl_pkcs7_sign() returns its headers and body with bare LF line
breaks. They were copied into the message verbatim, so signed mail was
rejected by SMTP servers that enforce RFC 5321 line endings with
550 5.6.11 SMTPSEND.BareLinefeedsAreIllegal.

Fixes #3067
This commit is contained in:
dualfroz committed 2026-09-10 08:11:24 +02:00
1 parent c138873d49
commit 709e2d5b62
2 files changed
+8 -2

No files matched your search

+5
View File
@@ -971,6 +971,11 @@ EOT;
$msg = $this->Mail->getSentMIMEMessage();
self::assertStringNotContainsString("\r\n\r\nMIME-Version:", $msg, 'Incorrect MIME headers');
self::assertSame(
0,
preg_match_all("/(?<!\r)\n/", $msg),
'Signed message contains bare line feeds'
);
unlink($certfile);
unlink($keyfile);
}