I finally found a patch.
First, I modified a file to expose the laminas-mail error.
Instead of getting a very generic error message:
Excessive errors processing emails for ssl://outlook.office365.com:995/POP (...).
Please manually check the Fetch Folder () [1/30 - 0/6]
I now got :
Excessive errors processing emails for ssl://outlook.office365.com:995/POP (...).
Please manually check the Fetch Folder () [1/30 - 0/6]
({a}[Line "?Received: from YQBPR01MB10811.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:75::17)" does not match header format!]
{a}[Line "?Received: from YQBPR0101MB8941.CANPRD01.PROD.OUTLOOK.COM" does not match header format!]
{a}[Line "?Received: from YT1PPFE9BA3AC85.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b08::59f)" does not match header format!]
{a}[Line "?Received: from QB1PPF87FBA53A5.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c08::259)" does not match header format!]
{a}[Line "?Received: from YQBPR0101MB5563.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:44::6)" does not match header format!]
{a}[Line "?Received: from YT2PR01MB9859.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:d9::15)" does not match header format!]
)
The error message “does not match header format!” comes from
include/laminas-mail/src/Headers.php, in the fromString() function.
After adding a few error_log() calls, I noticed that the string passed to fromString() begins with a UTF-8 BOM.
A simple patch at the beginning of the function fixes the issue:
// Patch: strip UTF-8 BOM
$string = preg_replace('/^\xEF\xBB\xBF/', '', $string);
After this change, all emails start appearing correctly in osTicket.