This paper briefly describes the principle of the decoding of mail and MIME messages through POP3 protocol, and provides two practical PHP classes for collection and MIME decoding, and provides examples for use. It is divided into two parts: Mail collection and MIME decoding. Here we first introduce you to the mail collection, decoding part will be in the future of the article for you detailed introduction, please pay attention to.
Now the biggest application on the Internet should be non-email mo, we are accustomed to every day through email exchange, major sites have almost launched their own web-based free mail system. In this article, I will introduce some of the principles of email implementation. At the same time we assume that you have a certain basis for PHP programming, TCP/IP protocol also has a certain understanding.
Introduction to POP Protocols
Pop's full name is Postofficeprotoco, that is, the Post Office Protocol, used for e-mail reception, is now commonly used in the third edition, referred to as POP3. Through the POP protocol, the client log on to the server, you can delete their own messages, or download to the local, after downloading, e-mail customer software can be local to the mail modification, delete and so on. Another message to receive mail is the IMAP protocol, which is now developing quickly, which we will not discuss in this article.
POP server is generally used TCP port 110th, if you are using foxmail words, in its inbox, you can see its message prompt window has so some commands:
“正在连接到 62.123.23.123:110";
"USERBOSS_CH";
"PASS..............";
Let's take a look at a transcript of the conversation with the POP3 server:
telenetpop.china.com110
+OKAIMCPOPservice(mail2.china.com)isready.
USERboss_ch
+OKPleaseenterpasswordforuser.
PASS******
+OKboss_chhas1messages(750octets)
STAT
+OK1750
LIST
+OK1messages(750octets)
1750
RETR1
+OK750octets
Received:fromsmtp2.ptt.js.cn([202.102.24.37])bychina.com(JetMail2.5.3.0)
withSMTPidjm4839cc4227;Sat,23Sep200005:31:21-0000
Received:fromchenjunqing([61.155.120.6])bysmtp2.ptt.js.cn
(NetscapeMessagingServer4.15)withSMTPidG1BRHJ03.V07for
;Sat,23Sep200013:34:31+0800
Date:Sat,23Sep200013:34:18+0800
From:=?ISO-8859-1?Q?=B3=C2=BF=A1=C7=E5?=
To:boss_ch@china.com
Subject:=?ISO-8859-1?Q?=D3=CA=BC=FE=CA=BE=C0=FD?=
X-mailer:FoxMail3.1[cn]
Mime-Version:1.0
Content-Type:text/plain;charset="GB2312"
Content-Transfer-Encoding:8bit
Message-ID:
Hello!
This is a small example of a message
QUIT
+OKPopserveratsigningoff.
The following is a brief introduction to several commonly used POP3 commands:
Command parameter Status description
------------------------------------------
USER username approval of this command and the following pass command, if successful, will result in a state transition
Pass Password approved
APOP Name,digest approved Digest is MD5 message digest
------------------------------------------
STAT None processing requests the server to send back statistics about mailboxes, such as total number of messages and total bytes
UIDL [msg#] handles a unique identifier that returns a message, and each identifier for the POP3 session will be unique
LIST [msg#] handles the number of messages returned and the size of each message
RETR [msg#] handles the return of all text for a message identified by a parameter
The DELE [msg#] processing server marks the message identified by the parameter as deleted, executed by the QUIT command
RSET the None processing server resets all messages marked for deletion to undo the dele command
The top [msg#] processing server returns the first n rows of messages identified by the parameter, n must be a positive integer
The NOOP None processing server returns a positive response without any action.
------------------------------------------
QUIT None Update exit