Decoding of POP3 messages with PHP (i.)

Source: Internet
Author: User
Tags base64 mail microsoft outlook

Initial understanding of the source file of the message

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. We have introduced you to the receipt of the mail, and now let us introduce you to the decoding section of this article.

In the previous article, we have completed a use of PHP through the POP3 to collect e-mail instances, but in the use of this class, I believe you have seen, a lot of mail down is a pile of garbled, they can not understand! Yes. Now most of the mail has been encoded, need a decoding process to become our custom text, pictures, or other accessories.

The source file for the message

First, let's take a look at a simple message source file: (in Foxmail, select the message, click "View Source" to see this)

From: <boss_ch@netease.com>
To: <boss_ch@china.com>
Subject: =?gb2312? b?xoo6w6oh?=
Date:sun, 8 Oct 2000 20:28:45 +0800
mime-version:1.0
content-type:multipart/alternative;
boundary= "----=_nextpart_000_0007_01c03166.5b1e9510"
X-priority:3
X-msmail-priority:normal
X-mailer:microsoft Outlook Express 5.00.2919.6700
x-mimeole:produced by Microsoft MimeOLE V5.00.2919.6700
This is a multi-part message in MIME format.
------=_nextpart_000_0007_01c03166.5b1e9510
Content-type:text/plain;
charset= "gb2312"
Content-transfer-encoding:base64
w7vt0mlswuuwyao/dqo=
------=_nextpart_000_0007_01c03166.5b1e9510
content-type:text/html;
charset= "gb2312"
Content-transfer-encoding:base64
Pcfet0nuwvbfiehutuwgufvcteldicitly9xm0mvl0rurcbive1midqumcbucmfuc2l0aw9uywwv
L0voij4ncjxive1mpjxirufepg0kpe1fveegy29udgvudd0idgv4dc9odg1soybjagfyc2v0pwdi
mjmxmiigahr0cc1lcxvpdj1db250zw50lvr5cgu+dqo8tuvuqsbjb250zw50psjnu0hutuwgns4w
mc4yotiwljaiig5hbwu9r0vorvjbve9spg0kpfnuwuxfpjwvu1rzteu+dqo8l0hfquq+dqo8qk9e
wsbiz0nvbg9ypsnmzmzmzmy+dqo8relwpjxgt05uihnpemu9mj7du9pqwtlc67djo788l0zptlq+
pc9esvy+pc9ct0rzpjwvsfrntd4ncg==
------=_nextpart_000_0007_01c03166.5b1e9510-

Such a piece of mail, I think no one can understand. Don't worry, let's take a closer look at the content.

From: <boy@netease.com>

To: <boss_ch@china.com>

This is well understood, the mail is sent by the boy@netease.com, the recipient is boss_ch@china.com, the meaning of these tags can be literally understood, like Date:sun, 8 Oct 2000 20:28:45 +0800 indicates the time, X-priority:3 represents the priority of the message, X-mailer:microsoft Outlook Express 5.00.2919.6700 is the name of the mail transmitter, which uses Outllook 5, but These things do not have much to do with the content of the mail. We don't need to delve into it.

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.