473,782 Members | 2,393 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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('lo calhost')
M.user(getpass. getuser())
M.pass_(getpass .getpass())
numMessages = len(M.list()[1])
for i in range(numMessag es):
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
2 3029
On Jul 25, 1:18*pm, SteveC <sbc...@gmail.c omwrote:
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('lo calhost')
M.user(getpass. getuser())
M.pass_(getpass .getpass())
numMessages = len(M.list()[1])
for i in range(numMessag es):
* * 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
On Jul 25, 6:07*pm, MRAB <goo...@mrabarn ett.plus.comwro te:
On Jul 25, 1:18*pm, SteveC <sbc...@gmail.c omwrote:
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('l ocalhost')
M.user(getpass. getuser())
M.pass_(getpass .getpass())
numMessages = len(M.list()[1])
for i in range(numMessag es):
* * 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2483
by: Robin Becker | last post by:
Hi, I'm getting vast numbers of fake upgrade emails containing some kind of virus. My rather old client can be made to reject these based on some patterns in the subject line. They're nearly all based on the word 'New', 'Latest', 'Microsoft', 'Patch', 'Pack', ... etc etc. Is there a python tool that can be made to delete these from my POP3 mail box rather than let my client reject? Quite a few seem to have semi-valid return addresses so...
1
2708
by: p-nut | last post by:
newbie here needing some help. Is there a way to set up a script that will check a pop3 account and autosave the file attachments to a folder specified? The thing is: I have 1 single email account that will always have emails with nothing but emails with attachments. Since there will be thousands of these emails , I would like to be able to check a couple times a day this account and have the script auto save all
4
3731
by: Paul Schmidt | last post by:
Dear list: I am new to python, and I am trying to figure out the short answer on something. I want to open a POP3 mailbox, read the enclosed mail using the POP3 module, , and then process it using the email module. Environment Python 2.3.4, Mandrake Linux 9.0 patched up the wazoo...
2
2698
by: Steve Greenland | last post by:
For the poplib.POP3 object, docs say: list() Request message list, result is in the form (response, ). If which is set, it is the message to list. But (I've folded the long line): Python 2.3.5 (#2, May 4 2005, 08:51:39) on linux2
1
1740
by: Kevin F | last post by:
Having some troubles downloading messages with POP3... I can connect to the server just fine and list messages without any problem with the following code: ------------------------ from poplib import * server = POP3("mail.bluebottle.com") print server.getwelcome()
8
1647
by: Kevin F | last post by:
Having some troubles downloading messages with POP3... I can connect to the server just fine and list messages without any problem with the following code: ------------------------ from poplib import * server = POP3("mail.bluebottle.com") print server.getwelcome()
1
2252
by: Kevin F | last post by:
I have the following script: emails = for msg in messagesInfo: msgNum = int(msg.split()) msgSize = int(msg.split()) if(msgSize < 20000): message = server.retr(msgNum) Message = join(message, “\n”) emails.append(message)
1
10068
by: bobano | last post by:
Hi everyone, I am writing a POP3 Client program in Perl. You connect to a POP3 Server and have a running conversation with the mail server using commands from the RFC 1939 Post Office Protocol. This program can perform 5 options from a menu on your POP3 mail by logging in with the correct POP3 server along with a user name and password that you use to log in to your ISP. The user name and password as well as the server name are all hard-coded...
9
9409
by: flit | last post by:
Hello All, Using poplib in python I can extract only the headers using the .top, there is a way to extract only the message text without the headers? like remove the fields below: " Return-Path: X-Original-To: Received: from
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9946
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.