Socket + pop3: automatically receiving emails from 163 mailboxes 3

Source: Internet
Author: User
In socket + pop3 to automatically import emails from 163 mailboxes to the database 2, we have obtained emails from 163 mailboxes locally, and printed on the screen in "socket + pop3 to automatically store mails with 163 mailboxes 2", we have taken mails with 163 mailboxes to the local device and printed them on the screen.
We analyzed one of them and found that the strings printed on the screen were garbled. at this time, let's look at its source code and we will find the following: sorted ed: from smtpbg215.qq.com (unknown [112.90.139.244]) by mx31 (Coremail) with SMTP id UcCowEC580rk8NdP8IDfBA --. 15324S2; Wed, 13 Jun 2012 09:46:12 + 0800 (CST) DKIM-Signature: v = 1; a = rsa-sha256; c = relaxed/relaxed; d = qq.com; s = s0907; t = 1339551973; bh = ljnUlxrsjwAoFovC3HvrtJEA8h1g4B9XeCOvvQQduM8 =; h = X-QQ-SSF: X-HAS-ATTACH: X-QQ-BUSINESS-ORIGIN: X-Originat Ing-IP: X-QQ-STYLE: X-QQ-mid: From: To: Subject: Mime-Version: Content-Type: Content-Transfer-Encoding: Date: X-Priority: message-ID: X-QQ-MIME: X-Mailer: X-QQ-Mailer; B = iP/paper/Paper + MYS8oHTx5YSwLsNGLF906cSwpmgthgv0H3JGyUYmG87nX-QQ-SSF: 0000000000000f00000000000000000000x-has-attach: noX-QQ-BUSINESS-ORIGIN: 2X-Originating-IP: 116.246.199.191X-QQ -STYLE: X-QQ-mid: webmail439t1339551973t3228From: "=? Gb18030? B? TPO9q778? = "<305460883@qq.com> To:" =? Gb18030? B? CGhwMzAw? =" Subject: =? Gb18030? B? Va/J7l/E47rDX7LiytQ =? = Mime-Version: 1.0Content-Type: multipart/alternative; boundary = "---- = _ blank" Content-Transfer-Encoding: 8 BitDate: Wed, 13 Jun 2012 09:46:13 + 0800X-Priority: 3Message-ID: X-QQ-MIME: TCMime 1.0 by TencentX-Mailer: QQMail 2. xX-QQ-Mailer: QQMail 2. xX-CM-TRANSID: UcCowEC580rk8NdP8IDfBA --. 15324S2X-Coremail-Antispam: container is a multi-part message in MIME format. ------ _ NextPart_4FD7F0E5_DD9328F0_57DBE530Content-Type: text/plain; charset = "gb18030" Content-Transfer-Encodi Ng: base641eLKx9K7uPay4srU08q8/sW2 ------ = _ NextPart_4FD7F0E5_DD9328F0_57DBE530Content-Type: text/html; charset = "gb18030" Content-Transfer-Encoding: upload + xbY8YnI + PC9kaXY + ------ = _ NextPart_4FD7F0E5_DD9328F0_57DBE530 -- you can see that I put This is a multi-part message in MIME format. this sentence is red because it is the line between the message header and the message body (in our example, the message header and the message body are decoded separately ). For the moment, let's look at the message header. In the message header, I added the four lines in green. You can find that the sender, recipient, time, and topic we need are in it. However, we will find that a lot of very important information is? Gb18030? B? Va/J7l/E47rDX7LiytQ =? = Something in this form. Let's analyze what is actually =? Encoding? Encryption type (B/Q )? Encrypted content? =. Here, the encryption type may be B or Q. B indicates that base64_decode is used for decoding, and Q indicates that quoted_printable_decode is used for decoding. Our steps are as follows: 1. extract the decoded content. 2. select the decoding function based on the encrypted letter. 3. perform decoding based on the encoding. The decoding method is not provided here. you can try to write it down. I will put the code in the attachment.

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.