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
Updates on PicoRuby Networking, HPKE (and maybe more)
sylph01
1
190
Adding Security to Microcontroller Ruby
sylph01
2
3.1k
Secure Messaging at IETF 118
sylph01
0
63
Adventures in the Dungeons of OpenSSL
sylph01
0
460
Community & RubyKaigi Showcase @ Ehime.rb Reboot Meetup
sylph01
0
290
Build and Learn Rails Authentication
sylph01
8
2k
Email, Messaging, and Self-Sovereign Identity (2021/05/28 edition)
sylph01
0
270
DNS Encryption and Its Controversies
sylph01
0
710
Email, Messaging, and SSI/DID (再放送)
sylph01
0
1.4k
Other Decks in Technology
See All in Technology
The Rise of LLMOps
asei
5
1.3k
DMARC 対応の話 - MIXI CTO オフィスアワー #04
bbqallstars
1
160
AIチャットボット開発への生成AI活用
ryomrt
0
170
BLADE: An Attempt to Automate Penetration Testing Using Autonomous AI Agents
bbrbbq
0
290
マルチモーダル / AI Agent / LLMOps 3つの技術トレンドで理解するLLMの今後の展望
hirosatogamo
37
12k
AWS Lambda のトラブルシュートをしていて思うこと
kazzpapa3
2
170
開発生産性を上げながらビジネスも30倍成長させてきたチームの姿
kamina_zzz
2
1.7k
Oracle Cloud Infrastructureデータベース・クラウド:各バージョンのサポート期間
oracle4engineer
PRO
28
12k
ExaDB-D dbaascli で出来ること
oracle4engineer
PRO
0
3.8k
Incident Response Practices: Waroom's Features and Future Challenges
rrreeeyyy
0
160
TanStack Routerに移行するのかい しないのかい、どっちなんだい! / Are you going to migrate to TanStack Router or not? Which one is it?
kaminashi
0
580
Terraform Stacks入門 #HashiTalks
msato
0
350
Featured
See All Featured
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
A better future with KSS
kneath
238
17k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
Scaling GitHub
holman
458
140k
How STYLIGHT went responsive
nonsquared
95
5.2k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
It's Worth the Effort
3n
183
27k
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প