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

Mail being set as seen - BODY.PEEK vs BODY

Open themullet opened this issue 2 years ago • 5 comments

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.

themullet avatar Nov 03 '22 17:11 themullet

Hi, same issue here.

nettunodev avatar Nov 14 '22 20:11 nettunodev

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

willregelmann avatar Dec 09 '22 17:12 willregelmann

for fetchheader the old function make BODY.PEEK as default.

epocci avatar Dec 28 '22 13:12 epocci

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...)

GregoryHarvest avatar Jan 09 '23 16:01 GregoryHarvest

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]']);

hpetercek avatar Jun 13 '24 13:06 hpetercek