Lecture 32 - More Streams & Sockets
The default port for a POP server is 110.
Here are the commands provided by a POP server:
USER usernameThis command tells the POP server which user's mail to read. Instead of username you would identify the account to log into. This command responds with a single line which starts with the string +OK.
PASS passwordThis command tells the POP server the password corresponding to the previous user account. Instead of password you would provide the user's actual password. This command responds with a single line. If the line begins with +OK the login worked. If the login failed, it returns a line beginning with -ERR.
The remaining commands will only work after a successful login.
STATThis returns some simple statistics about the mailbox. The line it returns has the following form:
+OK 3 496The first number reports the number of messages in the mailbox. The second reports the total number of characters in all the messages.
TOP 1 0This returns the header of the message followed by some number of lines. The first number identifies the message number to return. The second number indicates how many lines of the message body to return. As shown above, the command would return only the header for the 1st message.
This message returns first with a line that begins either with +OK or -ERR. It the line it returns begins with +OK, it then sends multiple lines that are the header and the number of body lines requested. You can tell when there it is done sending lines because the last line will consist of a single period character (.).
RETR 1This command is a lot like TOP except that it returns the entire message requested, both header and body, in their entirety. The number you provide is the message number.
This command returns first with a line that begins either with +OK or -ERR. It the line it returns begins with +OK, it then sends multiple lines that are the header and complete body of the mail message requested. You can tell when there it is done sending lines because the last line will consist of a single period character (.).
QUITThis command ends the connection with the mail server. It always returns with a single line beginning with +OK.
You can try out this commands using telnet to connect to a mail server on port 110. Just type in the commands shown above and see the responses that you get back.
There is another example program that is similar to your lab project this week. It involves sending objects over a network.