By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,286 Members | 1,250 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,286 IT Pros & Developers. It's quick & easy.

POP3 - Using poplib only shows the first few hundred messages in themailbox

P: n/a
Hello,

I am trying to use POP3_SSL class of the poplib module to read email
from my gmail account. I can connect just fine using the example here
http://www.python.org/doc/lib/pop3-example.html

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
That is the above sample code from the python doc. While everything
works fine, the problem is that when I use the list() function it only
returns about 400 messages starting from the beginning of my inbox. I
have probably 10,000 emails in my gmail account. I don't see any pop3
object functions to "move" around the inbox or anything of the like.

Could someone point me in the right direction? I'm sure there must be
something simple I am missing.

Thanks,
Steve
Jul 25 '08 #1
Share this Question
Share on Google+
2 Replies

P: n/a
On Jul 25, 1:18*pm, SteveC <sbc...@gmail.comwrote:
Hello,

I am trying to use POP3_SSL class of the poplib module to read email
from my gmail account. *I can connect just fine using the example herehttp://www.python.org/doc/lib/pop3-example.html

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

That is the above sample code from the python doc. *While everything
works fine, the problem is that when I use the list() function it only
returns about 400 messages starting from the beginning of my inbox. *I
have probably 10,000 emails in my gmail account. *I don't see any pop3
object functions to "move" around the inbox or anything of the like.

Could someone point me in the right direction? *I'm sure there must be
something simple I am missing.
That's a lot of emails! :-)

I had a quick look at poplib.py and I couldn't see any limit in the
code itself. Perhaps it's the gmail server that's doing it. Can you
retrieve the later messages, eg have you tried M.retr(500)? If you can
then you could just try retrieving messages beyond what M.list() says
until it says there's no such message.
Jul 25 '08 #2

P: n/a
On Jul 25, 6:07*pm, MRAB <goo...@mrabarnett.plus.comwrote:
On Jul 25, 1:18*pm, SteveC <sbc...@gmail.comwrote:
Hello,
I am trying to use POP3_SSL class of thepoplibmodule to read email
from my gmail account. *I can connect just fine using the example herehttp://www.python.org/doc/lib/pop3-example.html
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
That is the above sample code from the python doc. *While everything
works fine, the problem is that when I use the list() function it only
returns about 400 messages starting from the beginning of my inbox. *I
have probably 10,000 emails in my gmail account. *I don't see any pop3
object functions to "move" around the inbox or anything of the like.
Could someone point me in the right direction? *I'm sure there must be
something simple I am missing.

That's a lot of emails! :-)

I had a quick look atpoplib.py and I couldn't see any limit in the
code itself. Perhaps it's the gmail server that's doing it. Can you
retrieve the later messages, eg have you tried M.retr(500)? If you can
then you could just try retrieving messages beyond what M.list() says
until it says there's no such message.
Nothing changes when I retrieve the messages it first provides me.
What baffles me is I see tons of examples online doing the same thing:
http://python.about.com/od/simplersc...up_gmail_3.htm

I'm not sure if it could be just a gmail thing either, because then it
would seem that this would be a problem with any pop email client.
Jul 30 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.