popstat() returns the number of undeleted elements. That should be related to the highest numbered message if you haven't deleted anything this session.

uidl( msgnum ) returns the UIDL of the given message.

Since POP3 servers tend to number messages from oldest to newest, if your last message's UIDL has been seen, all previous ones should have been seen. If it hasn't, you could decrement the message number and get the UIDL of each in turn until one you've seen. Once you've seen one, you've seen all the previous ones.

As a side note, you may want to consider downloading and storing the messages themselves in the database, if that would work for your application. Unlike IMAP, POP3 is not really designed nor intended to be used as long-term storage of email messages. VPS servers tend to have a huge amount of disk space and just a bit of memory. Using the database for your storage allows you to query the DB and grab just the information you need into memory (apart from overheard of course).


In reply to Re: pop3 issue by mr_mischief
in thread pop3 issue by GaijinPunch

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.