Checking for 'new' POP3 mail

Skip Montanaro skip at mojam.com
Wed Sep 15 16:18:07 EDT 1999


    > 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.

    > I thought I'd take this list, chop off the message number and put the
    > unique message values into a list on the very first pass. On all other
    > sweeps of the POP3 spool, I could create a second list and then check
    > against the first to see if there were any new, unique message id's
    > (and if so, do some checking on them for further action). Then the
    > original list would be tossed away and replaced with the last list as
    > it would be more up to date.

If it's going to run for long periods of time, your users (especially if
they are overworked sys admins who subscribe to waaay too many Python-
related mailing lists) will pile up lots of email.  I'd use a dict with UIDL
strings as keys, then pickle the dict.  Reconstitute it during startup and
use that as the basis for deciding new vs. old.

Skip Montanaro | http://www.mojam.com/
skip at mojam.com | http://www.musi-cal.com/~skip/
847-971-7098   | Python: Programming the way Guido indented...





More information about the Python-list mailing list