views:

52

answers:

2

Hi All

I was wondering if anyone could help me out (not with code, although that would be appreciated), with the logic behind checking and retrieving messages from a POP3 mail server.

I.e.

Establish connection
Validate credentials
Enumerate message list
Check each message to see if it's "new"
Download "new" message(s).

Would this be the correct way about doing this?

Thank you

+2  A: 

These should be useful:

bignum
Thank you. I have tried many other components which never worked. So I thought my best bet would be to understand how it is done and roll out my own implementation. Great links, thanks!
lucifer
+2  A: 

The best way of looking at something like this is to have a look what something else does. Run Wireshark or some other packet capture software, and use an e-mail client to check. Anyway, the basics of a POP3 session are as follows:

USER username
PASS password
LIST                <-- Shows the size of each waiting message
UIDL                <-- Shows a unique ID for each waiting message
RETR 1              <-- Retrieves message with index 1
DELE 1              <-- Deletes the message you just retrieved
QUIT

The first char of all of the responses except RETR will be a + (success) or a - (failure).

If you are deleting messages off the server after retrieving them, you don't need to bother with UIDL. If you are leaving them, you can use UIDL to get a unique ID for each message which you store locally to show you have retrieved that message before.

For more details, see the RFC. Wikipedia also lists a more in depth example, showing the server response.

Richard
+1 for the RFC link
Oddthinking
Thank you, Richard. Exactly what I was looking for.
lucifer