1

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?

Mohit Ranka
  • 4,193
  • 12
  • 41
  • 41

4 Answers4

2

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
  • 109,922
  • 25
  • 130
  • 137
2

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

Eugene Morozov
  • 15,081
  • 3
  • 25
  • 32
1

Why don't you try to use libgmail?

Rodrigo
  • 5,938
  • 6
  • 31
  • 39
0

It's the problem of gmail: https://mail.google.com/support/bin/answer.py?answer=13291

Try to use recent:username@gmail.com as your email address. At least you'll have all your last month mail in correct order.

Vanuan
  • 31,770
  • 10
  • 98
  • 102