I recently switched permanently to the plain html version of gmail because it plays better with vimperator and now I have 4000 unread messages that were hidden in the social and promotion tabs. I want to mark all those as read. Is there a way to do that without requesting for each message like they do here with imaplib
Asked
Active
Viewed 705 times
1 Answers
2
If you want to mark absolutely everything in your INBOX as read, execute this IMAP command after logging in and SELECT
ing the INBOX
:
tag STORE 1:* +FLAGS (\Seen)
You can do this with imaplib, any socket library, or just a SSH enabled TCP program, such as socat
or openssl s_client
.
Here's a transcript of the commands necessary to mark all messages read with GMail:
$ openssl s_client -connect imap.gmail.com:993 -crlf
* OK Gimap ready for requests from 208.65.73.143 f185mb90387173ioe
a LOGIN [username] [password]
* CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE ENABLE MOVE CONDSTORE ESEARCH UTF8=ACCEPT
a OK [username] [name] authenticated (Success)
b SELECT INBOX
* FLAGS (\Answered \Flagged \Draft \Deleted \Seen $Phishing $Forwarded Yellow $NotPhishing)
* OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen $Phishing $Forwarded Yellow $NotPhishing \*)] Flags permitted.
* OK [UIDVALIDITY 7] UIDs valid.
* 3617 EXISTS
* 0 RECENT
* OK [UIDNEXT 39807] Predicted next UID.
* OK [HIGHESTMODSEQ 4076284]
b OK [READ-WRITE] INBOX selected. (Success)
c STORE 1:* +FLAGS (\Seen)
* 1 FETCH (FLAGS (\Seen))
* 2 FETCH (FLAGS (\Seen))
...
* 3617 FETCH (FLAGS (\Seen))
c OK Success
d LOGOUT
* BYE LOGOUT Requested
d OK 73 good day (Success)
If you have a lot of messages, you may want to use +FLAGS.SILENT
with the STORE
command, which won't cause it to echo the results back to you.

Max
- 10,701
- 2
- 24
- 48
-
Awesome, although for future reference I had to tell google to let me log in from a 'less secure app' from here https://www.google.com/settings/security/lesssecureapps – fakedrake Sep 02 '14 at 15:52