views:

136

answers:

3

I want to get all the messages from my gmail inbox, but I am facing 2 problems.

  1. It does not get all the emails, (as per the count in stat function)
  2. The order of emails it get is random.

I am unsure if its the problem with poplib or gmail pop server.

What am I missing here?

A: 

Why don't you try to use libgmail?

Rodrigo
libgmail will limit the scope to gmail alone, which does not serve the purpose
Mohit Ranka
+1  A: 

What does your code look like? Using poplib, you're able to decide on the order and number of the messages downloaded. The code from the poplib documentation should work:

import getpass, poplib

M = poplib.POP3('localhost')
M.user(getpass.getuser())
M.pass_(getpass.getpass())
numMessages = len(M.list()[1])
for i in range(numMessages):
    for j in M.retr(i+1)[1]:
        print j
Can Berk Güder
+1  A: 

You can also try imaplib module since GMail also provides access to email via IMAP protocol.

Eugene Morozov