Using PHP to achieve POP3 mail (a) _php

Source: Internet
Author: User
Keywords receive mail implement server process protocol OK command POP
POP3

Introduction to the POP protocol
(Author: Chen Junqing October 18, 2000 11:53)

This paper briefly describes the principle of receiving the decoding of mail and MIME messages through the POP3 protocol, and provides two useful PHP classes for collecting and mime decoding, and provides examples of using. It is divided into two parts: Mail charge and MIME decoding. Here we first introduce you to the mail collection, decoding part will be in a future article for you detailed introduction, please pay attention.

  

Now the largest application on the Internet should be non-email, we are accustomed to daily through the exchange of email, the major sites have also almost launched their own web-based free mail system. In this article, I will introduce some of the principles of e-mail implementation. At the same time, we assume that you have a certain basis for PHP programming, the TCP/IP protocol also has a certain understanding.

Introduction to the POP protocol
The full name of the pop is the post Office Protoco, the Post Office Protocol, which is used for e-mail reception, and is now commonly used in the third edition, referred to as POP3. Through the POP protocol, after the client logs on to the server, can delete their own messages, or download to the local, after downloading, the e-mail client software can be local to the message to modify, delete, and so on. Another message for receiving letters is the IMAP protocol, which is now developing quickly, and we will not discuss it in this article.

The POP server typically uses TCP port 110th, and if you use Foxmail, you can see some of the commands in the message prompt window when you receive it:

"Connecting to 62.123.23.123:110";

"USER boss_ch";

"PASS ...";; ";";

Let's look at a transcript of a conversation with the POP3 server:

Telenet pop.china.com 110

+ok AIMC POP Service (mail2.china.com) is ready.

USER boss_ch

+ok Please enter password for user .

PASS ******

+ok Boss_ch has 1 messages (octets)

STAT

+ok 1 750

LIST

+ok 1 messages (octets)

1 750

RETR 1

+ok octets

Received:from smtp2.ptt.js.cn ([202.102.24.37]) by china.com (JetMail 2.5.3.0)

with SMTP ID jm4839cc4227; Sat, SEP 2000 05:31:21-0000

Received:from chenjunqing ([61.155.120.6]) by smtp2.ptt.js.cn

(Netscape Messaging Server 4.15) with SMTP ID g1brhj03. V07 for

   ; Sat, SEP 2000 13:34:31 +0800

Date:sat, SEP 2000 13: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:foxmail 3.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

+ok Pop Server at Signing off.

Here is a brief introduction to several commonly used POP3 commands:

Command parameter Status description

------------------------------------------

USER Username recognizes that this command and the following pass command, if successful, will result in a state transition

PASS Password Approval

APOP name,digest recognition Digest is MD5 message digest

------------------------------------------

Stat None processes the request server to send back statistics about the mailbox, such as the total number of messages and the total number of bytes

UIDL [msg#] handles the unique identifier of the returned 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#] processing returns all the text of the message identified by the parameter

DELE [msg#] processing server marks the message identified by the parameter for deletion, executed by the QUIT command

RSET None processing server resets all messages marked for deletion to undo the dele command

Top [msg#] processing server returns the first n rows of the message identified by the parameter, n must be a positive integer

NOOP None The processing server returns a positive response and does nothing.

------------------------------------------

Quit None Update exits
  • Related Article

    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.