Slide 1

Slide 1 text

Email in Rails, and/or Introduction to the "Dark Depths of Email" Ryo Kajiwara(sylph01) @ Fukuoka.rb #149/150

Slide 2

Slide 2 text

୭ʁ sylph01 / ֿݪ ཾ Twitter: @s01 ҉߸ͱ͔Ͱ͖·͢ Elixirͱ͔Ͱ͖·͢ Ruby·ΔͰΘ͔ΒΜ

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

W3CͷձٞͰདྷ·ͨ͠ ͍Ζ͍Ζweb-relatedͳεςοΧʔͱ ͔͋ΔͷͰ͋ͱͰ੠͔͚͍ͯͩ͘͞

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

RailsͰϝʔϧͷ͢΂ͯ Λѻ͑ΔΑ͏ʹͳͬ ͨʂ

Slide 9

Slide 9 text

MTAʮ΁ͷʯೖΓޱΛ උ͍͑ͯΔɺͱ͋Δ͚ ͲɺͲͪΒ͔ͱ͍͏ͱ MTAʮ͔ΒͷʯೖΓޱ

Slide 10

Slide 10 text

͜Ε͸ԿΛ͢Δ΋ͷͧ • ड৴ϝʔϧΛActiveRecordΦϒδΣΫτʹม׵ • ActiveStorageͰϥΠϑαΠΫϧ؅ཧɺҰఆظؒܦͬͨΒࣗಈম ٫ʢ࡟আʣ • ϝʔϧΛड͚ͨͱ͖ͷॲཧΛॻ͚Δ

Slide 11

Slide 11 text

ݸਓͰϝʔϧ΍Δͷ͸͓͢͢ Ί͠·ͤΜ • IMAP΍ΔͱετϨʔδ஍ࠈʹؕΓ·͢ • ໎࿭ϝʔϧରࡦ͸͠ΜͲ͍ • ઃఆϛεΔͱϝʔϧ͕૬खʹಧ͖·ͤΜ • ͱ͍͏͔SMTPΛ΍ΊΖ

Slide 12

Slide 12 text

ͳͷͰGuidesʹॻ͍ͯ͋ΔΑ ͏ʹWebαʔϏεΛ࢖͓͏ • Mailgun • Mandrill • Postmark • SendGrid • ·ͨ͸Amazon SESʢଞʹൺ΂Δͱࣗ෼ͰMTA؅ཧ͢Δͷʹۙ͘ ͸͋Δʣ

Slide 13

Slide 13 text

ͦΕͰ΋΍Γͨ͘ͳͬ ͨͱ͖ͷ࿩Λ͠·͢

Slide 14

Slide 14 text

஫: ͔͜͜ΒNot Ruby Rubyͷݴ༿ͰؤுΓ͔͚ͨͬͨͲؒ ʹ߹Θͳ͔ͬͨΑ…

Slide 15

Slide 15 text

SMTP Ͳ͕͜Simple΍ͶΜMail Transfer Protocolɻ RFC 821 → ݱࡏͷ࠷৽͸ RFC 5321 ʮϝʔϧΛόέπϦϨʔͷΑ͏ʹసૹ͢ΔʯͷͰʮSMTP relayingʯͱ͔ʮϦϨʔαʔόʔʯͱ͔͍͏͚ΕͲݱ୅తʹ͸͜ͷ Πϝʔδ͸࣋ͬͯͳͯ͘Α͍Ͱ͢ɻ૬खઌυϝΠϯ໊ͷMXϨίʔ υΛݟͯ௚઀ͦ͜ʹୟ͖͚ͭ·͢ɻ

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

SMTPʹ͸ೝূ͕ͳ͍ SMTP͸ϦϨʔػߏΛ࡞ΔͨΊͷϓϩτίϧͳͷͰɺͲ͔͜Βϝʔ ϧ͕དྷ͔ͨΛ͍͍ͪͪೝূ͢Δඞཁ͕ͳ͍ɻཧ۶͸Θ͔Δͷ͚ͩ Ͳ໎࿭ϝʔϧ͕͸ͼ͜Δ࠷େͷݪҼͷҰ͕ͭ͜Εɻ POP before SMTPɺSMTP-AUTHͳͲͷ֦ுͰೝূΛ͢Δɻ

Slide 18

Slide 18 text

SPF, DKIM ͜ͷϝʔϧ͸ͪΌΜͱ͜ͷυϝΠϯΛॴ༗͍ͯ͠Δਓʢͷαʔ όʔʣ͔Βདྷͯ·͢Αɺͱ͍͏͜ͱΛ͍ࣔͨ͠ɻ ͲͪΒ΋DNSͷTXTϨίʔυʹهड़Λߦ͏ɻ • SPF: ڐՄ͢ΔIPΞυϨεΛࢦఆɻ • DKIM: ެ։伴ΛTXTϨίʔυʹઃఆɻαʔόʔ͸ൿີ伴Λར༻͠ ͯϝοηʔδʹॺ໊͢Δɻ

Slide 19

Slide 19 text

SPF TXTϨίʔυʹIPΞυϨεɺ΋͘͠͸MXϨίʔυͷυϝΠϯ໊Λࢦ ఆ͢Δ͚ͩɻ ྫ: example.net. IN TXT "v=spf1 ip4:192.0.2.1 -all"

Slide 20

Slide 20 text

DKIM • opendkimΛΠϯετʔϧͯ͠ઃఆ͢Δ • ΍Δ͜ͱଟ͍ͷͰৄࡉ͸DigitalOceanͷνϡʔτϦΞϧࢀর - https:/ /www.digitalocean.com/community/tutorials/how-to- install-and-configure-dkim-with-postfix-on-debian-wheezy • ެ։伴ɾൿີ伴ϖΞͷੜ੒ͱTXTϨίʔυͷੜ੒Λ΍ͬͯ͘ ΕΔ

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

DMARC • ϔομʹࣔ͞ΕΔૹ৴ऀͷυϝΠϯ(Header-From)ͱMAIL FROM ίϚϯυͰ౉͞ΕΔૹ৴ऀͷυϝΠϯ(Envelope-From)ͷҰகΛ औΔ • Header-FromͷυϝΠϯ໊ͱDKIMͷ"d="Ͱ༩͑ΒΕΔυϝΠϯ ໊ͷҰகΛऔΔ ͱ͍͏௥ՃͷೝূΛ͢Δɻࣦഊͨ͠৔߹ʹυϝΠϯΦʔφʔʹ໰ ୊ͷ͋ΔϝʔϧΛใࠂͰ͖Δ࢓૊Έ΋͋Δɻ

Slide 23

Slide 23 text

SPF, DKIM, DMARCͷઃ ఆϛε͸͔ͳΓଟ͍ αʔϏε࢖ͬͯͯ΋DNSઃఆ๨ΕΔͱ ໎࿭ϝʔϧѻ͍͞Ε·͢

Slide 24

Slide 24 text

ड৴͢Δଆͱͯ͠͸ ʮ໎࿭ϝʔϧ͸ड৴ ϘοΫεʹೖͬͨ࣌఺ Ͱෛ͚ʯ MTAͰݕূͪΌΜͱ͠Α͏

Slide 25

Slide 25 text

ૹΔଆͰؾΛ͚ͭͳ ͖Ό͍͚ͳ͍͜ͱ

Slide 26

Slide 26 text

LTͩͱೖΓ੾Βͳ͍ͷ Ͱ؆୯ʹ঺հ

Slide 27

Slide 27 text

GoogleͷҰׅૹ৴ΨΠυϥΠ ϯ https:/ /support.google.com/a/answer/81126?hl=ja ૹΔଆ͸͜Εकͬͯͳ͍ͱ͍ͭͷؒʹ͔໎࿭ϝʔϧϑΥϧμߦ͖ ʹͳΓ·͢ɻ ૹ৴ϘϦϡʔϜ͕େ͖͍৔߹͸Postmaster ToolsΛ࢖͏ͱΑ͍ɻ

Slide 28

Slide 28 text

mail-tester.com https:/ /www.mail-tester.com/ ͜͜ʹϝʔϧૹΔͱIP͕ϒϥοΫϦετ͞ΕͯΔ͔Ͳ͏͔΍Ұൠ తͳઃఆϛεʹ͍ͭͯڭ͑ͯ͘ΕΔɻ

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

DigitalOcean͔Βૹͬͯ ͨΒMSNʹϒϩοΫ͞ ΕͯͨͰ͟͝Δ

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

چWILLCOMܥͷΞυϨ εʹ͸௨৴͢Βड͚෇ ͚ͯ΋Β͑ͳ͔ͬͨ

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

ݸਓͰϝʔϧ΍Δͷ͸͓͢͢ Ί͠·ͤΜ(࠶) • IMAP΍ΔͱετϨʔδ஍ࠈʹؕΓ·͢ • ໎࿭ϝʔϧରࡦ͸͠ΜͲ͍ • ઃఆϛεΔͱϝʔϧ͕૬खʹಧ͖·ͤΜ • ͱ͍͏͔SMTPΛ΍ΊΖ

Slide 35

Slide 35 text

ͳͷͰWebαʔϏεΛ࢖͓͏ (࠶) • Mailgun, Mandrill, Postmark, SendGrid, Amazon SES • αʔόʔӡ༻Λؙ౤͛Ͱ͖Δ͠ • ໎࿭ϝʔϧରࡦ΍ͬͯ͘ΕΔ • IPΞυϨεͷϨϐϡςʔγϣϯ؅ཧ΋΍ͬͯ͘ΕΔ

Slide 36

Slide 36 text

Ͳ͏ͯ͠΋΍Γ͍ͨ ํʹ͸ ΋͏ͪΐͬͱ౿ΈࠐΜͩ಺༰Λ"Dark Depths of SMTP"(ٕज़ॻయ4ॳग़)ͱ͍͏ ຊͰॻ͍͍ͯ·͢ ͜ͷ෼໺͸঎ۀຊ͕࠷ۙग़ͯͳ͍ͷͰ͓ ͦΒ͘࠷৽Ͱ͢ ͳ͓౦ํཁૉ͸දࢴ͚ͩͰ͢ɻ

Slide 37

Slide 37 text

Welcome to SMTPপ