Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
64
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

posted at

updated at

MIMEエンコードされたメールのデコード方法

メール本文のデコード

まずgmailの"メッセージのソースを表示する"をクリックする。そしてメール本文をコピーする。

encodingがbase64でcharsetがUTF-8の場合

Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: base64

pbpaste | nkf -mB

encodingが7bitで、charsetISO-2022-JPの場合

Content-Type: text/plain; charset="ISO-2022-JP"
Content-Transfer-Encoding: 7bit

pbpaste | nkf -J でデコード

encodingがquoted-printableで、charsetがUTF-8の場合

Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

pbpaste | nkf -mQ でデコード

encodingがbase64で、charsetがISO-2022-JPの場合

charset=ISO-2022-JP
Content-Transfer-Encoding: base64

pbpaste | base64 -D | nkf -Jpbpaste | nkf -mB でデコード

encodingが8bitで、charsetがShift_JISの場合

content-type:text/plain; charset="Shift_JIS"
content-transfer-encoding:8bit

gmailのエンコードをShift_JISにする。

Subject(件名)のデコード

ISO-2022-JP、quoted-printable

Subject: =?ISO-2022-JP?Q?iTunes_Movie_=1B$B%K%e!<%j%j!<%9$HCmL\:nIJ=1B(B?=

echo "=?ISO-2022-JP?Q?iTunes_Movie_=1B$B%K%e!<%j%j!<%9$HCmL\:nIJ=1B(B?=" | nkf -m でデコード

ISO-2022-JP、BASE64

Subject: =?ISO-2022-JP?B?GyRCJUElMSVDJUg5WEZ+JE4bKEI=?=
 =?ISO-2022-JP?B?GyRCJCpDTiRpJDshSiVmJUolJCVGJUMlSSEmJTclTSVeGyhCIA==?=
 =?ISO-2022-JP?B?GyRCJTAlayE8JVchSxsoQg==?=

echo "Subject: =?ISO-2022-JP?B?GyRCJUElMSVDJUg5WEZ+JE4bKEI=?==?ISO-2022-JP?B?GyRCJCpDTiRpJDshSiVmJUolJCVGJUMlSSEmJTclTSVeGyhCIA==?==?ISO-2022-JP?B?GyRCJTAlayE8JVchSxsoQg==?=" | nkf -m でデコード

改行を含んでいる状態で pbpaste | nkf -m でもデコードできる。

UTF-8、BASE64

Subject: =?UTF-8?B?44CQ44OX44Op44Kk44Og5Lya5ZOh44Gu5pa5?=
 =?UTF-8?B?44G444GK55+l44KJ44Gb44CRUHJp?=
 =?UTF-8?B?bWUgTm93IOOCqOODquOCouaLoeWkpyjmnbHkuqzjg7vljYPokYkp?=

pbpaste | nkf -m でデコード

UTF-8、quoted-printable

Subject: =?utf-8?Q?Distributed=20TensorFlow=E3=81=AE=E8=A9=B1?=

pbpaste | nkf -m でデコード

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
64
Help us understand the problem. What are the problem?