Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get email unread content, without affecting unread state [duplicate]

Right now its a gmail box but sooner or later I want it to scale.

I want to sync a copy of a live personal mailbox (inbox and outbox) somewhere else, but I don't want to affect the unread state of any unread messages.

what type of access will make this easiest? I can't find any information if IMAP will affect the read state, but it appears I can manually reset a message to unread. Pop by definition doesn't affect unread state but nobody seems to use pop to access their gmail, why?

like image 249
Dustin Getz Avatar asked Dec 22 '22 08:12

Dustin Getz


2 Answers

In the IMAP world, each message has flags. You can set the individual flags on each message. When you Fetch a message, it's actually possible to read the message, without applying the \Seen flag.

Most mail clients will apply the \Seen flag when the message is read. So, if the message has already been read, outside of your app, then you will need to remove the \Seen flag.

Just as fyi...here is the relevant part about flags from the RFCs:

A system flag is a flag name that is pre-defined in this specification. All system flags begin with "\". Certain system flags (\Deleted and \Seen) have special semantics described elsewhere. The currently-defined system flags are:

    \Seen
       Message has been read

    \Answered
       Message has been answered

    \Flagged
       Message is "flagged" for urgent/special attention

    \Deleted
       Message is "deleted" for removal by later EXPUNGE

    \Draft
       Message has not completed composition (marked as a draft).

    \Recent
       Message is "recently" arrived in this mailbox.  This session
       is the first session to have been notified about this
       message; if the session is read-write, subsequent sessions
       will not see \Recent set for this message.  This flag can not
       be altered by the client.

       If it is not possible to determine whether or not this
       session is the first session to be notified about a message,
       then that message SHOULD be considered recent.

       If multiple connections have the same mailbox selected
       simultaneously, it is undefined which of these connections
       will see newly-arrived messages with \Recent set and which
       will see it without \Recent set.
like image 105
dave wanta Avatar answered Jan 05 '23 18:01

dave wanta


There is a .PEEK option on the FETCH command in IMAP that will explicitly not set the /Seen flag.

Look at the FETCH command in RFC 3501 and scroll down a bit to page 57 or search for "BODY.PEEK".

like image 35
Dan Goldstein Avatar answered Jan 05 '23 18:01

Dan Goldstein