Checking for 'new' POP3 mail

Fredrik Lundh fredrik at pythonware.com
Wed Sep 15 16:59:15 EDT 1999


Python Addict <init__self at my-deja.com> wrote:
> The poplib works brilliantly but there doesn't seem to be an obvious
> built-in way to see what's 'new' between sweeps of the POP3 spool.

> Messages come and go so just purely checking on the number of messages in
> the spool isn't going to work. Our POP server supports the optional UIDL
> command which returns the message number, a space, and then a unique
> identifier for each message.

not only unique, but unique across sessions.  definitely
the right way to do this, as you had already figured out.

> Am I making things complex for no reason or is there some built in
> functionality I'm missing from the POP spec? Is there a Python-ish way of
> comparing two lists that I might not be aware of? I was going to start at
> the beginning of the second list, waddle through it, and search for each
> element in the first list.

it's probably easier to use a dictionary to keep track of
what UIDLs you've already seen.

on the other hand, a simple "for x in new: if x not in old:" loop
is probably fast enough for this purpose.

</F>





More information about the Python-list mailing list