Gmail imap search does not get all messages.

Bart Kastermans bkasterm at gmail.com
Tue Jan 29 21:23:56 EST 2008


I am trying to use imaplib with gmail.  I am finding however that with
the gmail server imaplib.search does not give the correct answer.  See
the below traces (k is a server a my department, i is gmail).
k has 6 messages in the INBOX
i has 3 messages in the INBOX

However i.search(None, "ALL")
only gives as answer "1 2", missing the third message.

Any suggestions about what I might be doing wrong?  Or is this a known
issue?  I couldn't find anything by googling, but maybe I am using the
wrong search terms.

Best,
Bart



>>> k.select()
  05:41.11 > FEIC2 SELECT INBOX
  05:41.16 < * FLAGS (\Answered \Flagged \Deleted \Seen \Draft MATH
$Forwarded $label5 $label1 $label4 $label2 $label3 NonJunk $NotJunk
$Junk JunkRecorded)
  05:41.16 < * OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen
\Draft MATH $Forwarded $label5 $label1 $label4 $label2 $label3 NonJunk
$NotJunk $Junk JunkRecorded \*)] Flags permitted.
  05:41.16 < * 6 EXISTS
  05:41.16 < * 0 RECENT
  05:41.16 < * OK [UIDVALIDITY xXxXxXxXxX] UIDs valid
  05:41.16 < * OK [UIDNEXT xXxXxXxX] Predicted next UID
  05:41.16 < FEIC2 OK [READ-WRITE] Select completed.
('OK', ['6'])
>>> k.search(None,"ALL")
  05:52.82 > FEIC3 SEARCH ALL
  05:52.86 < * SEARCH 1 2 3 4 5 6
  05:52.86 < FEIC3 OK Search completed.
('OK', ['1 2 3 4 5 6'])

>>> i.select()
  10:23.16 > DKNG10 SELECT INBOX
  10:23.30 < * FLAGS (\Answered \Flagged \Draft \Deleted \Seen)
  10:23.30 < * OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted
\Seen \*)]
  10:23.30 < * OK [UIDVALIDITY xXxXxXxXx]
  10:23.30 < * 3 EXISTS
  10:23.30 < * 0 RECENT
  10:23.30 < * OK [UNSEEN 3]
  10:23.30 < * OK [UIDNEXT 7]
  10:23.31 < DKNG10 OK [READ-WRITE] INBOX selected. (Success)
('OK', ['3'])
>>> i.search(None,"ALL")
  10:17.30 > DKNG9 SEARCH ALL
  10:17.44 < * SEARCH 1 2
  10:17.44 < DKNG9 OK SEARCH completed (Success)
('OK', ['1 2'])



More information about the Python-list mailing list