Improve folding of too long headers
Author: mhchemCreated Oct 30, 2019Updated Nov 19, 2019
When a header gets too long and has no white space for folding, it gets RFC1342-Q-encoded. #1840
However, this leads to lines that are too long (similar to #36 issue 2).
In-Reply-To: =?us-ascii?Q?<33E3D825-9C3C-4F74-867D-3D4520379AD4=3D=3Dxxxxxxxxxxxx.de@x?=
=?us-ascii?Q?xxx.de>?=
This could be prevented by a folding directly after the colon.
In-Reply-To:
=?us-ascii?Q?<33E3D825-9C3C-4F74-867D-3D4520379AD4=3D=3Dxxxxxxxxxxxx.de@x?=
=?us-ascii?Q?xxx.de>?=
This is allowed because RFC 5322 states:
references = "References:" 1*msg-id CRLF
msg-id = [CFWS] "<" id-left "@" id-right ">" [CFWS]
Furthermore, this initial white space should be considered when determining if Q-encoding is necessary. Because the best solution would be the following output, IMHO.
In-Reply-To:
<33E3D825-9C3C-4F74-867D-3D4520379AD4=3D=3Dxxxxxxxxxxxx.de@xxxx.de>
Thirdly, you might want to apply Q-encoding only to words that are too long. If there is just one word longer than 76 characters, there is no need to Q-encode the whole header in pieces of 59 characters.
Source: PHPMailer/PHPMailer