Hi,
those are not comments. According to RFC 2822 CFWS syntax, comments would be enclosed in parentheses, which is not the case here. Message with comments would be parsed without issues:
Date: 20 Apr 2022 10:03:29 +0200
(To: abc@def.com)
(From: <ghi@jkl.com>)
Indenting a line actually makes it a continuation of the previous line - therefore, the indented 'To' and 'From' lines are actually part of the 'Date' header, so equivalent to this:
Date: 20 Apr 2022 10:03:29 +0200 To: abc@def.com From: <ghi@jkl.com>
Those strings are not comments, they are a part of the Data header, and that's why our parser fails.
Outlook, Windows Mail and Thunderbird are notably very benevolent about what they parse - for example, when I download a PNG image and save it as 'message.eml', Outlook does not complain at all and pretends it's a message with a body text of "Ê#d|eftxè‘oùÓyÓ! I¼" - we don't think emulating that in our mail library would be a good idea.
However, you can make our parser more benevolent by enabling MailMessage.Settings.IgnoreUnparsableHeaders
option - this will result in the parser ignoring the wrong 'Date' header (along with the emvedded 'To' and 'From' strings).
Unlike Rebex Mail with IgnoreUnparsableHeaders
, Outlook's 'Date' header parser actually discards the extra text and parses the beginning. We'll try making our 'Date' parser a bit more benevolent as well for the next release.