Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Email in Rails (and/or introduction to "Dark De...
Search
sylph01
September 18, 2019
Technology
0
1.2k
Email in Rails (and/or introduction to "Dark Depths of Email")
presented at Fukuoka.rb 150th anniversary LT
sylph01
September 18, 2019
Tweet
Share
More Decks by sylph01
See All by sylph01
"Actual" Security in Microcontroller Ruby!?
sylph01
0
66
Everyone Now Understands AuthZ/AuthN and Encryption Perfectly and I'm Gonna Lose My Job
sylph01
1
13
Updates on PicoRuby Networking, HPKE (and maybe more)
sylph01
1
210
Adding Security to Microcontroller Ruby
sylph01
2
3.2k
Secure Messaging at IETF 118
sylph01
0
74
Adventures in the Dungeons of OpenSSL
sylph01
0
480
Community & RubyKaigi Showcase @ Ehime.rb Reboot Meetup
sylph01
0
300
Build and Learn Rails Authentication
sylph01
8
2k
Email, Messaging, and Self-Sovereign Identity (2021/05/28 edition)
sylph01
0
280
Other Decks in Technology
See All in Technology
株式会社ログラス − エンジニア向け会社説明資料 / Loglass Comapany Deck for Engineer
loglass2019
3
32k
WACATE2024冬セッション資料(ユーザビリティ)
scarletplover
0
240
10分で学ぶKubernetesコンテナセキュリティ/10min-k8s-container-sec
mochizuki875
3
380
DUSt3R, MASt3R, MASt3R-SfM にみる3D基盤モデル
spatial_ai_network
2
210
私なりのAIのご紹介 [2024年版]
qt_luigi
1
120
3年でバックエンドエンジニアが5倍に増えても破綻しなかったアーキテクチャ そして、これから / Software architecture that scales even with a 5x increase in backend engineers in 3 years
euglena1215
7
2.4k
Oracle Cloud Infrastructure:2024年12月度サービス・アップデート
oracle4engineer
PRO
1
230
生成AIをより賢く エンジニアのための RAG入門 - Oracle AI Jam Session #20
kutsushitaneko
4
280
AWS re:Invent 2024で発表された コードを書く開発者向け機能について
maruto
0
210
社外コミュニティで学び社内に活かす共に学ぶプロジェクトの実践/backlogworld2024
nishiuma
0
280
APIとはなにか
mikanichinose
0
110
サービスでLLMを採用したばっかりに振り回され続けたこの一年のあれやこれや
segavvy
2
530
Featured
See All Featured
A Philosophy of Restraint
colly
203
16k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
Learning to Love Humans: Emotional Interface Design
aarron
274
40k
The Pragmatic Product Professional
lauravandoore
32
6.3k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Speed Design
sergeychernyshev
25
670
Making the Leap to Tech Lead
cromwellryan
133
9k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
Producing Creativity
orderedlist
PRO
342
39k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Transcript
Email in Rails, and/or Introduction to the "Dark Depths of
Email" Ryo Kajiwara(sylph01) @ Fukuoka.rb #149/150
୭ʁ sylph01 / ֿݪ ཾ Twitter: @s01 ҉߸ͱ͔Ͱ͖·͢ Elixirͱ͔Ͱ͖·͢ Ruby·ΔͰΘ͔ΒΜ
None
W3CͷձٞͰདྷ·ͨ͠ ͍Ζ͍Ζweb-relatedͳεςοΧʔͱ ͔͋ΔͷͰ͋ͱͰ͔͚͍ͯͩ͘͞
None
None
None
RailsͰϝʔϧͷͯ͢ Λѻ͑ΔΑ͏ʹͳͬ ͨʂ
MTAʮͷʯೖΓޱΛ උ͍͑ͯΔɺͱ͋Δ͚ ͲɺͲͪΒ͔ͱ͍͏ͱ MTAʮ͔ΒͷʯೖΓޱ
͜ΕԿΛ͢Δͷͧ • ड৴ϝʔϧΛActiveRecordΦϒδΣΫτʹม • ActiveStorageͰϥΠϑαΠΫϧཧɺҰఆظؒܦͬͨΒࣗಈম ٫ʢআʣ • ϝʔϧΛड͚ͨͱ͖ͷॲཧΛॻ͚Δ
ݸਓͰϝʔϧΔͷ͓͢͢ Ί͠·ͤΜ • IMAPΔͱετϨʔδࠈʹؕΓ·͢ • ໎ϝʔϧରࡦ͠ΜͲ͍ • ઃఆϛεΔͱϝʔϧ͕૬खʹಧ͖·ͤΜ • ͱ͍͏͔SMTPΛΊΖ
ͳͷͰGuidesʹॻ͍ͯ͋ΔΑ ͏ʹWebαʔϏεΛ͓͏ • Mailgun • Mandrill • Postmark • SendGrid
• ·ͨAmazon SESʢଞʹൺΔͱࣗͰMTAཧ͢Δͷʹۙ͘ ͋Δʣ
ͦΕͰΓͨ͘ͳͬ ͨͱ͖ͷΛ͠·͢
: ͔͜͜ΒNot Ruby Rubyͷݴ༿ͰؤுΓ͔͚ͨͬͨͲؒ ʹ߹Θͳ͔ͬͨΑ…
SMTP Ͳ͕͜SimpleͶΜMail Transfer Protocolɻ RFC 821 → ݱࡏͷ࠷৽ RFC 5321
ʮϝʔϧΛόέπϦϨʔͷΑ͏ʹసૹ͢ΔʯͷͰʮSMTP relayingʯͱ͔ʮϦϨʔαʔόʔʯͱ͔͍͏͚ΕͲݱతʹ͜ͷ Πϝʔδ࣋ͬͯͳͯ͘Α͍Ͱ͢ɻ૬खઌυϝΠϯ໊ͷMXϨίʔ υΛݟͯͦ͜ʹୟ͖͚ͭ·͢ɻ
None
SMTPʹೝূ͕ͳ͍ SMTPϦϨʔػߏΛ࡞ΔͨΊͷϓϩτίϧͳͷͰɺͲ͔͜Βϝʔ ϧ͕དྷ͔ͨΛ͍͍ͪͪೝূ͢Δඞཁ͕ͳ͍ɻཧ۶Θ͔Δͷ͚ͩ Ͳ໎ϝʔϧ͕ͼ͜Δ࠷େͷݪҼͷҰ͕ͭ͜Εɻ POP before SMTPɺSMTP-AUTHͳͲͷ֦ுͰೝূΛ͢Δɻ
SPF, DKIM ͜ͷϝʔϧͪΌΜͱ͜ͷυϝΠϯΛॴ༗͍ͯ͠Δਓʢͷαʔ όʔʣ͔Βདྷͯ·͢Αɺͱ͍͏͜ͱΛ͍ࣔͨ͠ɻ ͲͪΒDNSͷTXTϨίʔυʹهड़Λߦ͏ɻ • SPF: ڐՄ͢ΔIPΞυϨεΛࢦఆɻ • DKIM:
ެ։伴ΛTXTϨίʔυʹઃఆɻαʔόʔൿີ伴Λར༻͠ ͯϝοηʔδʹॺ໊͢Δɻ
SPF TXTϨίʔυʹIPΞυϨεɺ͘͠MXϨίʔυͷυϝΠϯ໊Λࢦ ఆ͢Δ͚ͩɻ ྫ: example.net. IN TXT "v=spf1 ip4:192.0.2.1 -all"
DKIM • opendkimΛΠϯετʔϧͯ͠ઃఆ͢Δ • Δ͜ͱଟ͍ͷͰৄࡉDigitalOceanͷνϡʔτϦΞϧࢀর - https:/ /www.digitalocean.com/community/tutorials/how-to- install-and-configure-dkim-with-postfix-on-debian-wheezy •
ެ։伴ɾൿີ伴ϖΞͷੜͱTXTϨίʔυͷੜΛͬͯ͘ ΕΔ
None
DMARC • ϔομʹࣔ͞ΕΔૹ৴ऀͷυϝΠϯ(Header-From)ͱMAIL FROM ίϚϯυͰ͞ΕΔૹ৴ऀͷυϝΠϯ(Envelope-From)ͷҰகΛ औΔ • Header-FromͷυϝΠϯ໊ͱDKIMͷ"d="Ͱ༩͑ΒΕΔυϝΠϯ ໊ͷҰகΛऔΔ ͱ͍͏ՃͷೝূΛ͢Δɻࣦഊͨ͠߹ʹυϝΠϯΦʔφʔʹ
ͷ͋ΔϝʔϧΛใࠂͰ͖ΔΈ͋Δɻ
SPF, DKIM, DMARCͷઃ ఆϛε͔ͳΓଟ͍ αʔϏεͬͯͯDNSઃఆΕΔͱ ໎ϝʔϧѻ͍͞Ε·͢
ड৴͢Δଆͱͯ͠ ʮ໎ϝʔϧड৴ ϘοΫεʹೖͬͨ࣌ Ͱෛ͚ʯ MTAͰݕূͪΌΜͱ͠Α͏
ૹΔଆͰؾΛ͚ͭͳ ͖Ό͍͚ͳ͍͜ͱ
LTͩͱೖΓΒͳ͍ͷ Ͱ؆୯ʹհ
GoogleͷҰׅૹ৴ΨΠυϥΠ ϯ https:/ /support.google.com/a/answer/81126?hl=ja ૹΔଆ͜Εकͬͯͳ͍ͱ͍ͭͷؒʹ͔໎ϝʔϧϑΥϧμߦ͖ ʹͳΓ·͢ɻ ૹ৴ϘϦϡʔϜ͕େ͖͍߹Postmaster ToolsΛ͏ͱΑ͍ɻ
mail-tester.com https:/ /www.mail-tester.com/ ͜͜ʹϝʔϧૹΔͱIP͕ϒϥοΫϦετ͞ΕͯΔ͔Ͳ͏͔Ұൠ తͳઃఆϛεʹ͍ͭͯڭ͑ͯ͘ΕΔɻ
None
DigitalOcean͔Βૹͬͯ ͨΒMSNʹϒϩοΫ͞ ΕͯͨͰ͟͝Δ
None
چWILLCOMܥͷΞυϨ εʹ௨৴͢Βड͚ ͚ͯΒ͑ͳ͔ͬͨ
None
ݸਓͰϝʔϧΔͷ͓͢͢ Ί͠·ͤΜ(࠶) • IMAPΔͱετϨʔδࠈʹؕΓ·͢ • ໎ϝʔϧରࡦ͠ΜͲ͍ • ઃఆϛεΔͱϝʔϧ͕૬खʹಧ͖·ͤΜ • ͱ͍͏͔SMTPΛΊΖ
ͳͷͰWebαʔϏεΛ͓͏ (࠶) • Mailgun, Mandrill, Postmark, SendGrid, Amazon SES •
αʔόʔӡ༻Λؙ͛Ͱ͖Δ͠ • ໎ϝʔϧରࡦͬͯ͘ΕΔ • IPΞυϨεͷϨϐϡςʔγϣϯཧͬͯ͘ΕΔ
Ͳ͏ͯ͠Γ͍ͨ ํʹ ͏ͪΐͬͱ౿ΈࠐΜͩ༰Λ"Dark Depths of SMTP"(ٕज़ॻయ4ॳग़)ͱ͍͏ ຊͰॻ͍͍ͯ·͢ ͜ͷۀຊ͕࠷ۙग़ͯͳ͍ͷͰ͓ ͦΒ͘࠷৽Ͱ͢ ͳ͓౦ํཁૉදࢴ͚ͩͰ͢ɻ
Welcome to SMTPপ