POP3 provides a special (temporary?) id that stays unique and unchanged at least during the time of the session, even when you delete messages: the uidl. You can use that as the basis for a better tracking system for which messages you've read: with two uidl hashes, you have both the old and the new message number, and by inverting one hash
%msgnum = reverse %uidl;
you can map
old message number -> uidl -> new message number
or, in Perl:
$new_msgnum = $msgnum2{$uidl1{$msgnum}};
As I currently don't have a pop3 mailbox available for testing purposes, I can't really test it and the code is just pseudocode, just giving a general outline, and not real working code.
But what I don't get... as long as the connection isn't closed, the messages aren't renumbered, or are they? That's how I remember it. | [reply] [d/l] [select] |
Pop3 servers allow access to messages by index ranging from 1 to n where there are n messages available. When messages are actually deleted (the deletes may be pending) the remaining messages will be reindexed.
Options are: remember how many messages remain on the server after deletions and start at the index following that number, read the message headers only and check the message id's to determine if the messages are new or not (assuming you keep the id's for messages that have been dealt with) or (as you suggest) check the date and times of messages.
DWIM is Perl's answer to Gödel
| [reply] |
See how I did it at Tk-POP3-previewer. You select those to be deleted, and do the actual deletion before disconnecting.
| [reply] |
Hi guys
I have been out drinking so can't really dig into this now, but I do appreciate the direction. I will check this out in the morning when I should be a bit more sober.
Bart: Right now, the session closes (the job is run via cron X times per day). I guess I should look into leaving it open and run like a daemon.
| [reply] |
| [reply] |