Ruby - UNIX MBOX 本文検証!
Updated:
今日は UNIX MBOX メールデータの本文の検証を行ってみました。 (検証には Ruby を使用していますが、ソースまでは公開していませんのであしからず)
本文の検証と言っても、
- Content-Type のタイプが “text”・未設定の場合のサブタイプ・文字コード・エンコード別の集計をしたり、
- Content-Type のタイプが “multipart” の場合の各パートをサブタイプ・文字コード・エンコード別に集計をしたり
- 本文が設定されていないものを集計したり
しました。
以下の当ブログ過去記事等ともダブる点もありますが、個人の記録として掲載していますので、ご了承ください。
- Ruby - UNIX MBOX メールヘッダ・Content-Type属性の検証!
- Ruby - UNIX MBOX メールヘッダ・Content-Transfer-Encoding属性の検証!
- Ruby - UNIX MBOX 本文Multipart検証!
ちなみに、Content-Type が設定されていないものは、”text/plain; charset=us-ascii” が設定されているものとしています。( RFC 2045 に準拠 ) また、Content-Type のタイプ/サブタイプに “multipart/alternative” が設定されている場合は、各パートの Content-Type のタイプが “text” のものを本文としてカウントしています。
参考までに、当方の61,665件のメールデータでの集計結果を掲載します。 また、以前の検証での若干の誤りも発見したので、最近の一連の作業でも後半になればなるほど精度は上がっていると確信しております。 ※これらの検証データについて「だから何?」と言われても、「近い将来に目論んでいる事のための自分用の記録です。」としか言いようがありません。あしからず。。。
メールヘッダの Content-Type のタイプに “text” が設定されているもの
Content-Type が非設定のものもタイプに “text” が設定されているものとして集計。 ※要は、メールに添付ファイル等が無く、本文単独のメール。
| サブタイプ | 文字コード | エンコード | 件数 |
|---|---|---|---|
| plain | ansi_x3.4-1968 | 7bit | 2,026 |
| plain | ascii | 7bit | 1 |
| plain | euc-jp | 7bit | 1,634 |
| plain | euc-jp | 8bit | 3 |
| plain | gb-2312 | base64 | 1 |
| plain | iso-2022-jp | 7bit | 31,160 |
| plain | iso-2022-jp | 8bit | 94 |
| plain | iso-2022-jp | base64 | 16 |
| plain | iso-2022-jp | quoted-printable | 78 |
| plain | iso-2022-jp-2 | 7bit | 1 |
| plain | iso-8859-1 | 7bit | 1,690 |
| plain | iso-8859-1 | quoted-printable | 3 |
| plain | iso-8859-8 | base64 | 2 |
| plain | shift-jis | base64 | 2 |
| plain | shift_jis | 7bit | 15 |
| plain | shift_jis | 8bit | 7 |
| plain | shift_jis | base64 | 2 |
| plain | shift_jis | quoted-printable | 1 |
| plain | us-ascii | 7bit | 4,295 |
| plain | us-ascii | quoted-printable | 31 |
| plain | utf-8 | 7bit | 4,487 |
| plain | utf-8 | 8bit | 62 |
| plain | utf-8 | base64 | 155 |
| plain | utf-8 | quoted-printable | 7 |
| plain | x-sjis | 7bit | 1 |
| html | euc-jp | quoted-printable | 1 |
| html | iso-2022-jp | 7bit | 5,468 |
| html | iso-2022-jp | base64 | 73 |
| html | iso-2022-jp | quoted-printable | 409 |
| html | iso-8859-1 | 7bit | 1 |
| html | iso-8859-1 | quoted-printable | 1 |
| html | shift_jis | quoted-printable | 1 |
| html | us-ascii | 7bit | 14 |
| html | us-ascii | quoted-printable | 19 |
| html | utf-8 | 8bit | 1 |
| html | utf-8 | base64 | 1 |
| html | utf-8 | quoted-printable | 3 |
メールヘッダの Content-Type のタイプに “multipart” が設定されているもの
本文が各パートに分割されるので、各パート毎に上記と同様に集計。 各パートのヘッダ部分に Content-Type が非設定のものはタイプに “text” が設定されているものとして集計。
| サブタイプ | 文字コード | エンコード | 件数 |
|---|---|---|---|
| plain | ansi_x3.4-1968 | 7bit | 1 |
| plain | iso-2022-jp | 7bit | 6,870 |
| plain | iso-2022-jp | 8bit | 319 |
| plain | iso-2022-jp | base64 | 5 |
| plain | iso-2022-jp | quoted-printable | 61 |
| plain | iso-8859-1 | 7bit | 1,454 |
| plain | iso-8859-1 | quoted-printable | 38 |
| plain | iso-8859-4 | 7bit | 1 |
| plain | shift_jis | base64 | 3 |
| plain | us-ascii | 7bit | 110 |
| plain | us-ascii | 8bit | 2 |
| plain | us-ascii | quoted-printable | 4 |
| plain | utf-8 | 7bit | 257 |
| plain | utf-8 | 8-bit | 2 |
| plain | utf-8 | 8bit | 32 |
| plain | utf-8 | base64 | 40 |
| plain | utf-8 | quoted-printable | 104 |
| plain | windows-1252 | 7bit | 2 |
| html | iso-2022-jp | 7bit | 5,887 |
| html | iso-2022-jp | base64 | 5 |
| html | iso-2022-jp | quoted-printable | 566 |
| html | iso-8859-1 | 7bit | 2 |
| html | iso-8859-1 | 8bit | 2 |
| html | shift_jis | base64 | 4 |
| html | shift_jis | quoted-printable | 346 |
| html | us-ascii | 7bit | 3 |
| html | us-ascii | base64 | 2 |
| html | us-ascii | quoted-printable | 39 |
| html | utf-8 | 7bit | 45 |
| html | utf-8 | 8bit | 7 |
| html | utf-8 | base64 | 44 |
| html | utf-8 | quoted-printable | 111 |
| rfc822-headers | us-ascii | 7bit | 2 |
Content-Type のタイプに “multipart” が設定されている場合、何番目のPartに本文が設定されているか集計
ここでは、各Partの本文とは、各Partの Content-Type のタイプに “text” が設定されているものを想定しています。
| Part | 件数 |
|---|---|
| 1番目 | 9,560 |
| 2番目 | 6,808 |
| 3番目 | 2 |
Content-Type のタイプに “multipart” が設定されている場合、1メールに何個の本文が設定されているかを集計
ここでは、各Partの本文とは、各Partの Content-Type のタイプに “text” が設定されているものを想定しています。
| 設定個数 | 件数 |
|---|---|
| 0個 | 335 |
| 1個 | 2,750 |
| 2個 | 6,810 |
本文が設定されていないものを集計
ここでは、本文とは、Content-Type のタイプに “text” が設定されているものを想定しています。
- 通常のメールヘッダ部分の Content-Type のタイプに “text” も “multipart” も設定されていないもの(下表の「ヘッダ」)
- メールヘッダ部分の Content-Type のタイプに “multipart” が設定されていても各Partの Content-Type のタイプに “text” が1つも設定されていないもの(下表の「ボディ」)
を集計しています。
| ヘッダ/ボディ | 件数 |
|---|---|
| ヘッダ | 4 |
| ボディ | 335 |
以上です。
Comments