views:

114

answers:

1

I understand most of the POP3 protocol, but one thing that bothers me is how POP3 clients efficiently get a list of unretrieved message ids from the POP3 server. Many services like Yahoo and Gmail now offer gigs of space and most people (myself included), rarely if ever delete an email message.

I'm currently implementing a simple POP3 client in C#, though the question that I'm asking should be language agnostic.

On the client side I store a list of ALL the retrieved message ids that I've ever retrieved. There is no need for this client to ever delete messages, mark messages ad having been read etc. All it needs to do is get the newest email messages since the last time that it connected to the POP3 server.

Am I right in assuming that the algorithm goes something like this:

  1. Retrieve ALL message IDs from the POP3 server. This list grows daily and can become megabytes in size easily.
  2. Compare this list of message IDs with the message IDs I have already retrieved (this list being stored client side) and identify what mail messages I actually have to retrieve from the server.
  3. Retrieve the mail messages one at a time from the server using the results from step 2 above.

Is there any way to make this more efficient?

+1  A: 

There's no really efficient way to do this, because POP was never designed for leaving messages in the mailbox permanently - it's designed for the use-case where you fetch your mail once and delete it.

A better approach to the whole problem would be to use IMAP instead, which is designed for efficient storage.

Nick Johnson