A preliminary understanding of the source file of the Mail this article briefly describes the principles of receiving mail and MIME mail through POP3 protocol, and provides two Practical PHP classes for receiving and MIME decoding, A sample is provided. Email receiving POP3
Get a preliminary understanding of the source file of the email
This article briefly describes the principles of receiving and MIME mail through POP3 protocol, provides two Practical PHP classes for receiving and MIME decoding, and provides samples for use. It is divided into two parts: email receiving and MIME decoding. We have already introduced you to receiving emails. now let's introduce you to the decoding department in this article.
In the previous article, we have completed an instance that uses PHP to receive emails through POP3. However, when using this class, I believe you have seen it, A lot of emails are garbled and cannot be understood! Yes. Most emails have been encoded. a decoding process is required to convert them into texts, images, or other attachments that we are used.
SOURCE file of the email
First, let's look at the source file of a simple email: (in Foxmail, select the email and click "View source file" to see such content)
From:
To:
Subject: =? Gb2312? B? XOO6w6Oh? =
Date: Sun, 8 Oct 2000 20:28:45 + 0800
MIME-type: 1.0
Content-Type: multipart/alternative;
Boundary = "---- = _ nextpart_000_0007_01c01_6.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_01c01_6.5b1e9510
Content-Type: text/plain;
Charset = "gb2312"
Content-Transfer-Encoding: base64
W7vT0MLSwuuwyaO/DQo =
------ = _ Nextpart_000_0007_01c01_6.5b1e9510
Content-Type: text/html;
Charset = "gb2312"
Content-Transfer-Encoding: base64
Bytes
Bytes
MjMxMiIgaHR0cC1lcXVpdj1Db250ZW50LVR5cGU + dqo8tuvuqsbjb250zw50psjnu0huuwgns4w
Mc4yotiwljaiig5hbwu9r0vorvjbve9sp1_kpfnuwuxfp1_vu1rzteu + DQo8L0hFQUQ + DQo8Qk9E
WSBiZ0NvbG9yPSNmZmZmZmY + dqo8relwpjxgt05uihnpemu9mj7du9pqwtlc67djo788l0zptscsi +
PC9ESVY + pc9ct0rzp?vsfrntd4ncg =
------ = _ Nextpart_000_0007_01c01_6.5b1e9510-
No one can understand such an email. Don't worry. let's take a closer look at the content.
From:
To:
This is well understood, the mail is sent by the boy@netease.com, the recipient is the boss_ch@china.com, the meaning of these labels we can basically literally understand, like Date: Sun, 8 Oct 2000 20:28:45 + 0800 indicates the time, X-Priority: 3 indicates the Mail Priority, and X-Mailer: Microsoft Outlook Express 5.00.2919.6700 indicates the mail sender name, outllook 5 is used here. However, these items are not closely related to the Mail content. We do not need to go further.
Author: Chen Junqing
Reprinted: chinacnet