in reply to POP3, only retrieving new messages

If you are using Net::POP3 you could use the uidl method to get a get a hash of the messages (the hash keys) and their unique identifiers (the hash values). Create a list in a file or DB table to store these unique ID. Each time you run your script have it get the ID's from the server and then compare these to those in your saved list. Foreach message ID that is not already in your save list, push it onto an array (@get_these). Now loop though this array and use the get method to pull only those you haven't already. After they messages have been retrieved (or in the same foreach loop) write them to your save list. You can read more about Net::Pop3 here.

-THRAK
www.polarlava.com

Replies are listed 'Best First'.
Re: Re: POP3, only retrieving new messages
by riffraff (Pilgrim) on Mar 31, 2001 at 01:27 UTC
    Yes, that's what I did when I was writing my email app (just learning, with Pike/GTK :). I think that is how the other clients do it also.

    Without a module, it would connect, list messages, and foreach message, do a top [id] 0 (to just get the headers), then parse out the Message-ID: field. I then kept a list (in Pike, a multiset was easiest) of all msgid's I've seen already, and only download a message (retr) that I hadn't seen.

    Of course, the module would do most of the for you. You would just have to keep a list of the msgid's.

    The previous message said the same thing, I realize, but I wanted to reiterate/confirm it.

    Anyway...

    riffraff