diff --git a/src/aiomail/client.py b/src/aiomail/client.py index c542ecd..c375266 100644 --- a/src/aiomail/client.py +++ b/src/aiomail/client.py @@ -229,10 +229,16 @@ class IMAPClient: return sorted(set(ids), reverse=True) async def fetch(self, email_id: int, *, icloud: bool = False) -> Optional[email.message.Message]: - """fetch and parse a full message by id""" + """fetch and parse a full message by id without setting \\Seen + + uses BODY.PEEK[]: RFC822 / BODY[] on a SELECTed mailbox set \\Seen as a side effect + (RFC 3501), so a fetched-then-rejected message would vanish from every later UNSEEN + search. only mark_seen() flags a message. `icloud` is kept for compatibility and is + now a no-op (BODY.PEEK[] already works there) + """ if not await self.ensure_connection(): return None - part = "(BODY[])" if icloud else "(RFC822)" + part = "(BODY.PEEK[])" try: if self.use_uid: result, data = await self._mail.uid("fetch", str(email_id), part)