Pro Yearly is on sale from $80 to $50! »

複数の言語環境に対する Eメールのエンコード方式選定

複数の言語環境に対する Eメールのエンコード方式選定

Loco Partners x VELTRA‎ 技術交流会 ( http://connpass.com/event/30968/ )での発表資料
複数の言語環境へ対してメール送信する際に、文字コード・転送エンコードをどうすべきかについて

E8c021e729dd97bba16bf37a9e7c755b?s=128

Yoshihiro Ohsuka

May 20, 2016
Tweet

Transcript

  1. ෳ਺ͷݴޠ؀ڥʹର͢Δ EϝʔϧͷΤϯίʔυํࣜબఆ גࣜձࣾ Loco Partners େਢլ ٛߒ 18/May/2016 Loco Partners

    x VELTRA ٕज़ަྲྀձ
  2. ࣗݾ঺հ • େਢլ ٛߒ • http://fb.com/ohsky • http://twitter.com/oh_sky • ࢓ࣄ

    • relux ( https://rlx.jp/ ) ͷ։ൃ • PHPϓϩάϥϜ • ΠϯϑϥपΓ • झຯ • Ϛϥιϯ (࠷ۙͩͱ౦ژϚϥιϯ) • μϜ (࠷ۙαϘΓؾຯ) • σϨες (࠷ۙ࢝ΊͨɻήʔϜID : 865788042)
  3. Eϝʔϧͱ͸ ిࢠϝʔϧ͸ɺίϯϐϡʔλωοτϫʔΫΛ࢖༻ͯ͠ɺ ༣ศͷΑ͏ʹ৘ใ౳Λަ׵͢ΔखஈͰ͋Δɻ (https://ja.wikipedia.org/wiki/ %E9%9B%BB%E5%AD%90%E3%83%A1%E3%83%BC%E3 %83%AB ΑΓҾ༻)

  4. Eϝʔϧͱ͸ ݱࡏɺΠϯλʔωοτͰ͸ɺϝʔϧαʔόؒͰͷ௨৴͓ΑͼΫ ϥΠΞϯτ͔Βͷૹ৴ʹ͸ɺҰൠʹSMTP͕࢖ΘΕΔɻ (https://ja.wikipedia.org/wiki/ %E9%9B%BB%E5%AD%90%E3%83%A1%E3%83%BC%E3 %83%AB ΑΓҾ༻)

  5. SMTPͱ͸ Πϯλʔωοτ(TCP/IP)্࢙࠷ݹͷϓϩτίϧͷҰͭ defined by RFC 821 in Aug 1982

  6. SMTP(RFC 821) Simple Mail Transfer Protocol • US-ASCII • Text

    Only
  7. MIME Multipurpose Internet Mail Extensions defined by RFC 2045 in

    Nov 1996
  8. MIME SMTPͷ֦ு࢓༷ ෳ਺จࣈίʔυɺϚϧνϝσΟΞ(ఴ෇ϑΝΠϧ)

  9. Eϝʔϧʹ͓͚ΔΤϯίʔυ MIMEͷنఆͰ͸ɺςΩετͷූ߸Խํࣜͱͯ͠ɺ ࣍ͷ2छྨͷ৘ใΛࢦఆ͢Δ • จࣈίʔυ(charset) • సૹΤϯίʔυ(Content-Transfer-Encoding)

  10. సૹΤϯίʔυͱ͸ EϝʔϧͷϝοηʔδBodyʹ͓͚Δɺ σʔλͷऔΓѻ͍ํ๏ • 7bit • Base64 • Quoted-Printable •

    8bit
  11. จࣈίʔυͱసૹΤϯίʔυ ͷ૊Έ߹Θͤྫ charset Content-Transfer-Encoding US-ASCII 7bit ISO-2022-JP 7bit UTF-8 Base64

    UTF-8 Quoted-Printable
  12. Base64ͱ͸ 3BytesΛ4จࣈͷASCIIจࣈʹม׵͢Δํࣜ ࢖༻͞ΕΔจࣈ͸ 0-9,A-Z,a-z,+,/ ͷ64छྨ σʔλͷ௕͞͸4/3ʹͳΔ

  13. Base64ͱ͸ Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 5a+/6ZmQ54Sh44CB5a+/6ZmQ54ShCgrkupTliqvjga7mk6bjgorliIfjgowKCua1t+egguWIqeaw tOmtmuOBrgoK5rC06KGM5pyrIOmbsuadpeacqyDpoqjmnaXmnKsKCumjn+OBhuWvneOCi+WHpuOB q+S9j+OCgOWHpgoK6Jeq44KJ5p+R5a2Q44Gu6Jeq5p+R5a2QCgrjg5HjgqTjg53jg5HjgqTjg50g 44OR44Kk44Od44Gu44K344Ol44O844Oq44Oz44Ks44OzCgrjgrfjg6Xjg7zjg6rjg7Pjgqzjg7Pj

    ga7jgrDjg7zjg6rjg7Pjg4DjgqQKCuOCsOODvOODquODs+ODgOOCpOOBruODneODs+ODneOCs+OD lOODvOOBruODneODs+ODneOCs+ODiuODvOOBrgoK6ZW35LmF5ZG944Gu6ZW35Yqp
  14. Base64ͷϝϦοτ จதʹASCIIจࣈҎ֎͕ଟ͍έʔε΍όΠφϦσʔλͰ͸ Quoted-PrintableΑΓ୹͘ͳΔ

  15. Quoted-Printableͱ͸ 1Byteͷ8bitίʔυΛ3จࣈͷASCIIจࣈʹม׵͢Δํࣜ 7bitίʔυ(ASCIIจࣈ)͸ม׵ͤͣ࢒͢ ม׵ʹ࢖༻͞ΕΔจࣈ͸ =,0-9,a-f

  16. Quoted-Printableͱ͸ Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable =E5=AF=BF=E9=99=90=E7=84=A1=E3=80=81=E5=AF=BF=E9=99=90=E7=84=A1=0A=0A= =E4=BA=94=E5=8A=AB=E3=81=AE=E6=93=A6=E3=82=8A=E5=88=87=E3=82=8C=0A=0A= =E6=B5=B7=E7=A0=82=E5=88=A9=E6=B0=B4=E9=AD=9A=E3=81=AE=0A=0A=E6=B0=B4= =E8=A1=8C=E6=9C=AB

    =E9=9B=B2=E6=9D=A5=E6=9C=AB =E9=A2=A8=E6=9D=A5=E6=9C= =AB=0A=0A=E9=A3=9F=E3=81=86=E5=AF=9D=E3=82=8B=E5=87=A6=E3=81=AB=E4=BD=8F= =E3=82=80=E5=87=A6=0A=0A=E8=97=AA=E3=82=89=E6=9F=91=E5=AD=90=E3=81=AE= =E8=97=AA=E6=9F=91=E5=AD=90=0A=0A=E3=83=91=E3=82=A4=E3=83=9D=E3=83=91= =E3=82=A4=E3=83=9D =E3=83=91=E3=82=A4=E3=83=9D=E3=81=AE=E3=82=B7=E3=83= =A5=E3=83=BC=E3=83=AA=E3=83=B3=E3=82=AC=E3=83=B3=0A=0A=E3=82=B7=E3=83=A5= =E3=83=BC=E3=83=AA=E3=83=B3=E3=82=AC=E3=83=B3=E3=81=AE=E3=82=B0=E3=83=BC= =E3=83=AA=E3=83=B3=E3=83=80=E3=82=A4=0A=0A=E3=82=B0=E3=83=BC=E3=83=AA= =E3=83=B3=E3=83=80=E3=82=A4=E3=81=AE=E3=83=9D=E3=83=B3=E3=83=9D=E3=82=B3= =E3=83=94=E3=83=BC=E3=81=AE=E3=83=9D=E3=83=B3=E3=83=9D=E3=82=B3=E3=83=8A= =E3=83=BC=E3=81=AE=0A=0A=E9=95=B7=E4=B9=85=E5=91=BD=E3=81=AE=E9=95=B7= =E5=8A=A9
  17. Quoted-PrintableͷϝϦοτ จதʹASCIIจࣈ͕ଟ͍έʔε(ϥςϯܥݴޠ)Ͱ͸ Base64ΑΓ΋୹͘ͳΔ͜ͱ͕ଟ͍ɻ

  18. Base64ͱQuoted-Printableͷൺֱ (೔ຊޠ) णݶແɺणݶແ ޒ߷ͷࡲΓ੾Ε ւ࠭རਫڕͷ ਫߦ຤ Ӣདྷ຤ ෩དྷ຤ ৯͏৸ΔॲʹॅΉॲ ᤵΒ׷ࢠͷᤵ׷ࢠ

    ύΠϙύΠϙ ύΠϙͷγϡʔϦϯΨϯ γϡʔϦϯΨϯͷάʔϦϯμΠ άʔϦϯμΠͷϙϯϙίϐʔͷϙϯϙίφʔͷ ௕ٱ໋ͷ௕ॿ ݪจ : 333 Bytes
  19. Base64ͱQuoted-Printableͷൺֱ (೔ຊޠ) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 5a+/6ZmQ54Sh44CB5a+/6ZmQ54ShCgrkupTliqvjga7mk6bjgorliIfjgowKCua1t+egguWIqeaw tOmtmuOBrgoK5rC06KGM5pyrIOmbsuadpeacqyDpoqjmnaXmnKsKCumjn+OBhuWvneOCi+WHpuOB q+S9j+OCgOWHpgoK6Jeq44KJ5p+R5a2Q44Gu6Jeq5p+R5a2QCgrjg5HjgqTjg53jg5HjgqTjg50g

    44OR44Kk44Od44Gu44K344Ol44O844Oq44Oz44Ks44OzCgrjgrfjg6Xjg7zjg6rjg7Pjgqzjg7Pj ga7jgrDjg7zjg6rjg7Pjg4DjgqQKCuOCsOODvOODquODs+ODgOOCpOOBruODneODs+ODneOCs+OD lOODvOOBruODneODs+ODneOCs+ODiuODvOOBrgoK6ZW35LmF5ZG944Gu6ZW35Yqp Base64 : 444 Bytes
  20. Base64ͱQuoted-Printableͷൺֱ (೔ຊޠ) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable =E5=AF=BF=E9=99=90=E7=84=A1=E3=80=81=E5=AF=BF=E9=99=90=E7=84=A1=0A=0A= =E4=BA=94=E5=8A=AB=E3=81=AE=E6=93=A6=E3=82=8A=E5=88=87=E3=82=8C=0A=0A= =E6=B5=B7=E7=A0=82=E5=88=A9=E6=B0=B4=E9=AD=9A=E3=81=AE=0A=0A=E6=B0=B4=

    =E8=A1=8C=E6=9C=AB =E9=9B=B2=E6=9D=A5=E6=9C=AB =E9=A2=A8=E6=9D=A5=E6=9C= =AB=0A=0A=E9=A3=9F=E3=81=86=E5=AF=9D=E3=82=8B=E5=87=A6=E3=81=AB=E4=BD=8F= =E3=82=80=E5=87=A6=0A=0A=E8=97=AA=E3=82=89=E6=9F=91=E5=AD=90=E3=81=AE= =E8=97=AA=E6=9F=91=E5=AD=90=0A=0A=E3=83=91=E3=82=A4=E3=83=9D=E3=83=91= =E3=82=A4=E3=83=9D =E3=83=91=E3=82=A4=E3=83=9D=E3=81=AE=E3=82=B7=E3=83= =A5=E3=83=BC=E3=83=AA=E3=83=B3=E3=82=AC=E3=83=B3=0A=0A=E3=82=B7=E3=83=A5= =E3=83=BC=E3=83=AA=E3=83=B3=E3=82=AC=E3=83=B3=E3=81=AE=E3=82=B0=E3=83=BC= =E3=83=AA=E3=83=B3=E3=83=80=E3=82=A4=0A=0A=E3=82=B0=E3=83=BC=E3=83=AA= =E3=83=B3=E3=83=80=E3=82=A4=E3=81=AE=E3=83=9D=E3=83=B3=E3=83=9D=E3=82=B3= =E3=83=94=E3=83=BC=E3=81=AE=E3=83=9D=E3=83=B3=E3=83=9D=E3=82=B3=E3=83=8A= =E3=83=BC=E3=81=AE=0A=0A=E9=95=B7=E4=B9=85=E5=91=BD=E3=81=AE=E9=95=B7= =E5=8A=A9 Quoted-Printable : 1007 Bytes
  21. Base64ͱQuoted-Printableͷൺֱ (෹ޠ) À bon vin point d'enseigne. ݪจ : 28

    Bytes w4AgYm9uIHZpbiBwb2ludCBkJ2Vuc2VpZ25lLg== Base64 : 40 Bytes =C3=80 bon vin point d’enseigne. Quoted-Printable : 32 Bytes
  22. సૹΤϯίʔυͱ͸ EϝʔϧͷϝοηʔδBodyʹ͓͚Δɺ σʔλͷऔΓѻ͍ํ๏ • 7bit • Base64 • Quoted-Printable •

    8bit
  23. 8bitΛආ͚Δ΂͖ཧ༝ ݹདྷͷSMTPͰ͸US-ASCIIલఏͩͬͨͨΊɺ 7bitίʔυ͔͠ѻ͑ͳ͍؀ڥ͕ଘࡏ͢Δ(͔΋͠Εͳ͍) ϝʔϧͷܦ࿏্ʹ7bit͔͠సૹͰ͖ͳ͍؀ڥ͕͋Δͱɺ σʔλ͕ഁଛ͢Δ εύϜϑΟϧλʔͷ৚݅ͱͯ͠ ʮContent-Transfer-Encoding: 8bitʯ ͕ઃఆ͞Ε͍ͯΔέʔε͕͋Δ (↑ੲεϥυͷίϝϯτͰݟͨ)

  24. ·ͱΊ • ݱ୅ʹ͓͍ͯ͸Լهͷ2ऀ୒Ұ • UTF-8, base64 • UTF-8, quoted-printable •

    ϥςϯޠܥͷςΩετΛૹΔ͜ͱ͕ଟ͍ͷͰ͋Ε͹
 Quoted-Printableɺͦ͏Ͱͳ͚Ε͹Base64 • reluxͰ͸೔ຊޠɾൟମࣈɾ؆ମࣈ͕ଟ͍ͷͰ
 Base64Λ࢖༻͍ͯ͠Δ
 (※ϝʔϧϚΨδϯ͸֎෦αʔϏεͷ౎߹Ͱquoted-printable)