我怎样才能解码电子邮件的内容?

How can I decode the content of the email?

我收到一封邮件:

Dear xxx,

Thank you. You have just ordered the ultimate treat for your taste buds.

Your yummy, lip smacking delight is being prepared with utmost love and attention at your own neighbouring Pizza Hut – Bengaluru - Airport Road....

但是当我说 "show original" 它显示为:

MIME-Version: 1.0
Sender: noreply@pizzahut.co.in
From: noreply@pizzahut.co.in
To: xxx@gmail.com
Reply-To: noreply@pizzahut.co.in
Date: 19 Sep 2014 19:44:26 +0530
Subject: PHD: Your order confirmation
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: base64
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - server.pizzahut.co.in
X-AntiAbuse: Original Domain - gmail.com
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - pizzahut.co.in
X-Get-Message-Sender-Via: server.pizzahut.co.in: authenticated_id: noreply@pizzahut.co.in

PCFET0NUWVBFIGh0bWwgUFVCTElDICItLy9XM0MvL0RURCBYSFRNTCAxLjAgVHJhbnNp
dGlvbmFsLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL1RSL3hodG1sMS9EVEQveGh0bWwx
LXRyYW5zaXRpb25hbC5kdGQiPjxodG1sIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8x
OTk5L3hodG1sIj48aGVhZD48bWV0YSBodHRwLWVxdWl2PSJDb250ZW50LVR5cGUiIGNv
bnRlbnQ9InRleHQvaHRtbDsgY2hhcnNldD11dGYtOCIgLz48dGl0bGU+UGl6emEgaHV0
PC90aXRsZT48L2hlYWQ+PGJvZHk+PHRhYmxlIHdpZHRoPSI2MDAiIGJvcmRlcj0iMCIg
Y2VsbHNwYWNpbmc9IjAiIGNlbGxwYWRkaW5nPSIwIj48dHI+PHRkIGFsaWduPSJjZW50
ZXIiIGJnY29sb3I9IiM5NjE3MDAiPjx0YWJsZSB3aWR0aD0iNjAwIiBib3JkZXI9IjAi
IGNlbGxzcGFjaW5nPSIwIiBjZWxscGFkZGluZz0iMCI+PHRyPjx0ZD48aW1nIHNyYz0i
aHR0cDovLzEwLjEyNy4yMDAuMzAvcGhpbmRpYS93ZWIvYXNzZXRzL1BISU4vSW1hZ2Vz

Gmail 客户端是如何解码这个模糊文本的内容的?此外,这是 Gmail API 特定的问题:这是 Gmail API 在返回内容时会为我解码的内容吗?

邮件是 base64 编码的。在浏览器中按 F12 打开开发者工具,然后对消息进行 base64 解码

atob("PCFET0NUWVBFIGh0bWwgUFVCTElDICItLy9XM0MvL0RURCBYSFRNTCAxLjAgVHJhbnNp dGlvbmFsLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL1RSL3hodG1sMS9EVEQveGh0bWwx LXRyYW5zaXRpb25hbC5kdGQiPjxodG1sIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8x OTk5L3hodG1sIj48aGVhZD48bWV0YSBodHRwLWVxdWl2PSJDb250ZW50LVR5cGUiIGNv bnRlbnQ9InRleHQvaHRtbDsgY2hhcnNldD11dGYtOCIgLz48dGl0bGU+UGl6emEgaHV0 PC90aXRsZT48L2hlYWQ+PGJvZHk+PHRhYmxlIHdpZHRoPSI2MDAiIGJvcmRlcj0iMCIg Y2VsbHNwYWNpbmc9IjAiIGNlbGxwYWRkaW5nPSIwIj48dHI+PHRkIGFsaWduPSJjZW50 ZXIiIGJnY29sb3I9IiM5NjE3MDAiPjx0YWJsZSB3aWR0aD0iNjAwIiBib3JkZXI9IjAi IGNlbGxzcGFjaW5nPSIwIiBjZWxscGFkZGluZz0iMCI+PHRyPjx0ZD48aW1nIHNyYz0i aHR0cDovLzEwLjEyNy4yMDAuMzAvcGhpbmRpYS93ZWIvYXNzZXRzL1BISU4vSW1hZ2Vz")

哪个会给你原邮件。

这是base64编码。任何 SMTP(简单邮件传输协议)MIME 对象都包含以下格式:

MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=frontier

This is a message with multiple parts in MIME format.
--frontier
Content-Type: text/plain

This is the body of the message.
--frontier
Content-Type: application/octet-stream
Content-Transfer-Encoding: base64

PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPHA+VGhpcyBpcyB0aGUg
Ym9keSBvZiB0aGUgbWVzc2FnZS48L3A+CiAgPC9ib2R5Pgo8L2h0bWw+Cg==
--frontier--

正文(在您的例子中是邮件内容)始终采用 base64 编码。 Wiki link 更深入地讨论这个,以防你想阅读。

http://en.wikipedia.org/wiki/MIME

要解码只需使用任何 base64 解码库(在 javascript 中)来读取内容。 (

此致,