Hi,
Here's a bug fix for Courier-IMAP 4.x and reading unread mail.
[Background]
New mails need to be flagged as Seen after it's opened. The IMAP command
STORE $UID +Flags (\$flag) is issued for this.
[Problem]
New mail cannot opened when using Courier-IMAP. No page is rendered.
[Solution]
Tcpdump reveals the following:
Client -> Server: flg STORE 139 +Flags (\Seen)
Server -> Client: * 139 FETCH (FLAGS (\Seen))
Server -> Client: flg OK STORE completed.
However, the 'flg' part is not stripped when the input is sent to
ParseResult to valid the server's response code (OK, BAD etc).
If we strip 'flg' before validating the response, we get the proper input.
File: program/lib/imap.inc:1455
Old code:
}while (!iil_StartsWith($line, "flg"));
if (iil_ParseResult($line) == 0){
File: program/lib/imap.inc:1455
New code:
}while (!iil_StartsWith($line, "flg"));
$line = str_replace('flg','',$line);
if (iil_ParseResult($line) == 0){
This patch shouldn't affect other IMAP-servers.
Core problem is that errors in imap.inc need to be logged using
error_log for example or a custom error handler. Otherwise a function
returns -1 and the exception is handled.
Best regards,
Jasper