javanile / php-imap2

PHP IMAP with OAUTH2
https://php-imap2.javanile.org/
GNU General Public License v3.0
48 stars 28 forks source link

Mail being set as seen - BODY.PEEK vs BODY #24

Open themullet opened 1 year ago

themullet commented 1 year ago

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.

nettunodev commented 1 year ago

Hi, same issue here.

willregelmann commented 1 year ago

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

epocci commented 1 year ago

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

GregoryHarvest commented 1 year ago

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

hpetercek commented 3 months ago

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