imap2maildir
imap2maildir copied to clipboard
Work around Google marking fetched messages as read
From an e-mail thread:
I've run into the same thing... I don't think it is "intentionally" being marked as read by the script or imaplib, but since the message is being downloaded, Google is marking it as read. I first noticed this around September of last year, if I recall correctly.
It has been awhile since I poked at it, but I think I tried two different approaches to work around this:
- Remember the original flags for the message, fetch the message, then set the flags back to the way they were.
- Hide the problem by only considering messages marked as "SEEN"
I ended up with the second solution (--search=CRITERIA, default to "SEEN"), in commit a708c659adda46e3f039cc0cdb1f7d84ea889bb6. This seems to work well with my workflow (run it nightly to back up the day's read messages), but revisiting the solution would be a very good idea. -rt
When attempting to use imap2maildir for the first time on a gmail account with over 3,000 messages with the default "SEEN" criteria only about 200 or so emails were pulled down. Specifying the "OLD" criteria allowed imap2maildir to see the full mailbox. This might be related to the fact the bulk of the 3,000 messages were pulled over from another gmail account via gmail's builtin pop import mechanism and those emails might be tagged differently somehow.
Just an FYI.
I believe a fetch (BODY.PEEK[]) instead of (RFC822) will do the trick.. Another thing we might want to add for each select(folder) is select(folder, readonly=True) which will execute "EXAMINE" instead of "SELECT" which is basically read/write mode.
Would you like a patch for these changes?