php-imap2
php-imap2 copied to clipboard
Mail being set as seen - BODY.PEEK vs BODY
Hi there, thanks for your great work on this. Recently migrated.
Initially thought the issue w with FT_PEEK, though after a bit of a rabbit hole found it was around BODY vs BODY.PEEK.
This was being used in imap2_fetch_overview + imap2_fetchheader and some other places.
I'm not sure how to do contribute to the code, though did a find and replace for BODY[ and changed to BODY.PEEK[ and mails not being set as seen now.
Thanks again for all your work on this.
Hi, same issue here.
I can confirm this issue as well. It looks like we should be using BODY.PEEK when the FT_PEEK flag is set, to maintain consistency with the old php-imap extension
for fetchheader the old function make BODY.PEEK as default.
Hi, we reproduce the issue as well (in imap2_fetchbody -> Javanile\Imap2\Message::fetchBody). Temporarily fixed by replacing BODY by BODY.PEEK
Is a fix planned please ?
bonus : Do you think other functions should be also fixed ? (ie : Javanile\Imap2\Message::body or Javanile\Imap2\Message::saveBody etc...)
I guess this issue is still present. This imap2 project is one of the most simple and straight forward replacements for old built-in imap.
I solved my "peek" problem by fixing body and fetchBody methods of Message class. There could also be other methods that ignore flags, but at this moment I needed these two.
I just added a peek flag check and modified command (modified fetchBody in a similar manner).
$isPeek = ($flags & FT_PEEK) ? ".PEEK": "";
$messages = $client->fetch($imap->getMailboxName(), $messageNum, $isUid, ['BODY'.$isPeek.'[TEXT]']);