imap
imap copied to clipboard
Message::getHeaders() does not parse message ID correctly
Hello, we had a problem with Message::getHeaders() method when loading an email sent from Office365.
The currently used imap_headerinfo did not load the Message-ID header's value at all. After some research we've found, that the problem is in Office365 including a newline before the value of the header.
An example of 2 emails, one sent from Office365, another from gmail:
Message-ID:
BYAPR04MB4021C4D3B9FD3A1BF451D2268C2F0@BYAPR04MB4021.namprd04.prod.outlook.com
VS
Message-Id: [email protected]
We fixed this by changing the https://github.com/ddeboer/imap/blob/4d3b31c7cc5eb3cf3a8a0369fabd0d6e3f39cede/src/Message.php#L155 line to:
$headers = \imap_rfc822_parse_headers($this->getRawHeaders());
Even though it's slower, it parses the value correctly.
Partial duplicate of https://github.com/ddeboer/imap/issues/385
We know the issue, but the performance impact of imap_fetchheader is huge.
A solution is still under research
The thing is, is this a bug in Office365 or in PHP's imap_headerinfo function? Maybe we should open a bug report in PHP?
I have the same issues with the In-Reply-To header.