php-imap icon indicating copy to clipboard operation
php-imap copied to clipboard

leaveUnread() does not work if an exception happens during fetching

Open freescout-help opened this issue 7 months ago • 3 comments

One user reported an issue https://github.com/freescout-help-desk/freescout/issues/4159. If an error occurs during fetching the email in the mailbox stays "read" even though leaveUnread() is set.

Here is the example of headers which can be used to reproduce the issue:

X-Mailer: CodeIgniter
Date: Thu, 1 Aug 2024 10:55:28 +0100
    Precedence: bulk
    Auto-Submitted: auto-replied
X-Priority: 1 (Highest)

We've found out that the following line marks an email as "read": https://github.com/Webklex/php-imap/blob/master/src/Query/Query.php#L246

if ($this->getFetchBody()) {
	$contents = $this->client->getConnection()->content($uids, "RFC822", $this->sequence)->validatedData();
}

So apparently somewhere in the code there should a place marking an email as "unread" if leaveUnread() is set. Is it so? If yes, can someone help to find that place in order to try to find a solution.

freescout-help avatar Aug 02 '24 05:08 freescout-help