POP3 protocol command source code and working principle

Source: Internet
Author: User

1 Introduction:

1. POP is applicable to the offline model email protocol of the C/S structure. It has been developed to the third edition, POP3. Offline models cannot be online
Unlike IMAP4 (netscape supports IMAP4)

2. When the client connects to the server and queries new emails, all emails that will be downloaded specified by the client will be downloaded
After the download, the email client can delete or modify any email without further interaction with the email server.

3. The POP3 client sends a command to the POP3 server and waits for a response. The POP3 command adopts the command line format and uses ASCII code.
A server response is composed of a single command line or multiple command lines. The first line of the response is indicated by ASCII text + OK or-ERR.
The operation status is successful or failed.

4. There are three statuses in POP3 protocol: approval status, processing status, and update status.
When the client establishes a connection with the server, once the client provides its own identity and is successfully confirmed, it is transferred from the recognized status to the processing status,
After the corresponding operation is completed, the client issues the quit command and enters the Update Status. After the update, the client returns to the approval status. For example

Wait for the quit command to confirm the connection identity
-- | Approval | ----- | processing | ------ | update |
| __________________________________ |
Return to approval status

5. Command statements in the Approval Status
Generally, most existing POP3 customers and servers use ASCII plain text to send user names and passwords, and are in the recognized status.
When the customer connects, the customer issues a connection and sends the plaintext user name and password to the server through the command user/pass.
Confirm your identity. Once confirmed, it is transferred to the processing status.
To avoid sending plaintext passwords, there is a new authentication method. The command is APOP and the password is encrypted before transmission.
When you connect to the server for the first time, the POP3 server sends an ASCII greeting to the client, which consists of a string of characters for each customer.
The user is unique and related to the time. Then, the client attaches its plain text password to the string received by the server,
Then calculate the MD5 single-output function message digest of the result string. The client sends the user name and MD5 message digest together as parameters of the APOP command.
Go out.
Currently, most mail client software on windows does not support APOP commands, and qpopper does.

6. The POP3 command code is as follows:
Command Parameter status description
------------------------------------------
USER username recognizes that if this command is successful with the following pass Command, status conversion will occur.
PASS password approval
APOP Name, Digest recognizes that Digest is the MD5 message Digest
------------------------------------------
STAT None processes the mailbox statistics sent back by the request server, such as the total number of emails and total bytes.
UIDL [Msg #] indicates the unique identifier of the Response Message. Each identifier of a POP3 session will be unique.
LIST [Msg #] Number of returned mails processed and size of each email
RETR [Msg #] process and return all text of the email identified by Parameters
DELE [Msg #] The processing server marks the emails marked by parameters as deleted and is executed by the quit command.
RSET None processing server resets all emails marked as deleted, used to cancel the DELE Command
TOP [Msg #] The processing server will return the content of the first n lines of emails identified by parameters. n must be a positive integer.
NOOP None processing server returns a positive response
------------------------------------------
QUIT None update

A. The client wants to end the session
B. If the server is in the 'process' status, it will enter the 'update' status to delete any emails marked as deleted
C. Changes from processing status to update status and return to approval status
D. If the server is in the 'approval' status when the command is issued, the session ends and the 'update' status is not performed.

7. The POP3 protocol waits for the client connection request on the TCP/110 port.

8. If the password is plain text, how can I listen?
The following command displays the POP3 connection and command sending process on the screen after the server runs:
# Sniffit-a-A.-p 110-B-s 192.169.11.12
Note: 192.168.11.12 is the Client IP address.
You need to install the sniffit port listener in advance

9. Considering this situation, if the customer is waiting for receiving 15 emails when receiving the email, but due to line problems, the customer is disconnected when receiving 10th emails,
Why does the last 10 emails still start from the first one, that is, why are they not deleted from the server?
   
You must delete all emails marked as deleted after the quit command is sent. Due to the disconnection, the deleted emails are still in
Unable to execute the quit command for status conversion.

10. pop3 session is locked by another session, please wait 10 minutes then try again.

The internal mechanism of the POP3 program locks this session due to abnormal operations.

11. The processing mechanism of Foxmail and OE (outlook express) is different.
 
A. Assume that there are three emails waiting for the client to receive on the server. The difference between foxmail and OE is that
Foxmail deletes one tag each time it receives it, and OE marks it all after it receives it as Delete and finally executes the quit command.

Foxmail OE
-------------------------------
Retr 1 retr 1
Dele 1 retr 2
Retr 2 retr 3
Dele 2 dele 1
Retr 3 dele 2
Dele 3 dele 3
Quit
B. Foxmail remote mail management is an excellent management tool. Assume that there are three emails on the server. We do not want to receive the first one.
You want to delete it directly from the server. For the second one, you want to receive but not delete it. For the third one, you do not want to receive it.
The Command sent by foxmail is

Dele 1
Retr 2
Quit

C. If there is no foxmail, just a few large emails are blocked. I don't want to accept it. I want to delete it directly or check who sent the two emails?

Use the command line in the windows DOS window, for example:
# Telnet my.isp.net 110
User username
Pass password
List
Dele 3
Dele 5
Quit

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.