POP3 Terminal Commands

It’s a while that I am thinking about developing a portal at our student community at University to monitor the part time jobs for robotics & nano-electronics students that are posted online (Finn.no is popular place to do so in Norway). Finally this would come up on a screen where robotics and Nano students would be hanging out.

For this purpose I have either thought to connect directly to the database (waiting for the response from the website). If they do not let me to do so, I was thinking to have the announcements sent to me with email (a service that the website offers) and then process the emails and update the list. To this I came across connecting to email servers with POP3 and using POP3 terminal commands to read emails (a tutorial on this subject) and update my list to show on the screen.

USER userid
First command after connecting. E-mail userid (this may or may not not the full e-mail address). Example: USER testuser

PASS password
Password of the email account. PASS thisPasswordIsCool

STAT
The response to this is: +OK #msgs #bytes Where #msgs is the number of messages in the mail box and #bytes is the total bytes used by all messages. Sample response: +OK 3 345910

LIST
The response to this lists a line for each message with its number and size in bytes, ending with a period on a line by itself. Sample response:
+OK 3 messages
1 1205
2 305
3 344400
.

RETR msg#
This sends message number msg# to you (displays on the Telnet screen). You probably don’t want to do this in Telnet (unless you have turned on Telnet logging). Example: RETR 2

TOP msg# #lines
This is an optional POP3 command. Not all POP3 servers support it. It lists the header for msg# and the first #lines of the message text. For example, TOP 1 0 would list just the headers for message 1, where as TOP 1 5 would list the headers and first 5 lines of the message text.

DELE msg#
This marks message number msg# for deletion from the server. This is the way to get rid a problem causing message. It is not actually deleted until the QUIT command is issued. If you lose the connection to the mail server before issuing the QUIT command, the server should not delete any messages. Example: DELE 3

RSET
This resets (unmarks) any messages previously marked for deletion in this session so that the QUIT command will not delete them.

QUIT
This deletes any messages marked for deletion, and then logs you off of the mail server. This is the last command to use. This does not disconnect you from the ISP, just the mailbox.

Source