Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Create Action Mailbox Sample Application
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
horikawa
June 25, 2019
Technology
450
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Create Action Mailbox Sample Application
horikawa
June 25, 2019
More Decks by horikawa
See All by horikawa
Caching associations in rails
casix
1
340
Rails 4.2→5.2アップデート
casix
0
460
Rails 6.0 Action Mailboxについて
casix
0
410
Other Decks in Technology
See All in Technology
DEFCON_CHV_CTF_Write-up.pdf
bata_24
0
140
深夜のクラウド懺悔室 1:29:300 or 1:0:0
kazzpapa3
1
240
Adaptive Warehouse を今すぐ導入すべき理由と迷ったときの判断基準
__allllllllez__
0
210
Microsoft 365 Copilot chat -tekoälypalvelun tietosuojaongelmat
hponka
0
820
アリアドネの糸と、20年ごとの建て替え ── 長尾真『電子図書館』を、伊勢で読み直す / Rereading Makoto Nagao’s "Electronic Library" in Ise
ykiyota
0
160
DEFCON34-Write-up_HYCu-MYCu
daikiokazaki
0
150
クロスボーダーM&AのValue Upを支えるプロダクト開発。日米チームのハブになったプロダクトエンジニアの実践 / Product Engineering Conference 2026
genda
0
120
2026-09-10 【Snowflake World Tour Tokyo 2026】dbt Core と Snowflake で実現する多層的なデータガバナンス / Multi-Layered Data Governance Powered by dbt Core and Snowflake
civitaspo
0
360
多層防御と最⼩権限で実現する、安全なAIエージェント設計パターン
lycorptech_jp
PRO
1
280
2026_devsumi_ozono.pdf
o3
3
450
Reactの設計論
uhyo
16
8.8k
Omarchy Quattro の日本語設定周り
simosako
2
160
Featured
See All Featured
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.4k
Crafting Experiences
bethany
1
330
Making Projects Easy
brettharned
120
6.7k
Heart Work Chapter 1 - Part 1
lfama
PRO
9
36k
Darren the Foodie - Storyboard
khoart
PRO
3
3.9k
Practical Orchestrator
shlominoach
191
12k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
780
So, you think you're a good person
axbom
PRO
2
2.1k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
202
76k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
Transcript
Rails 6.0ͷ Action Mailbox ݕূ (megurorb#28) גࣜձࣾπΫϧόɹαʔόαΠυΤϯδχΞ ງɹ@CASIXx1
• ීஈʮcowcamoʯͱ͍͏ΞϓϦΛ։ൃͯ͠ ·͢ • αʔόαΠυɺRailsʢ5.2ʣΛͬͯ·͢
Rails 6.0.0͕ͦΖͦΖग़ͦ͏ʂ
Rails 6.0.0.rc1͕ग़͍ͯΔͷ Ͱɺ΄΅6.0ͷػೳࢼͤΔʂ
৭ʑՃ͞Ε͍ͯΔ
Rails 6.0ͷओཁՃػೳ • Action Text • Action Mailbox • Multiple
Databases • Parallel Testing • Zeitwerk...etc
Action Textͷ ฉ͚͘Ͳɺɺ
Action Mailboxͷฉ͔ͳ͍... Qiitaϒϩά΄΅ͳ͍!
Action MailboxͰ αϯϓϧ࡞ͬͯΈ·ͨ͠
ݩʑɺผͷgemͱ࣮ͯ͠͞Ε ͍ͯͨ
ͪ͜Βͷϒϩάɺ gemΛࢼ͍ͯ͠Δ https://bagelee.com/programming/ruby-on-rails/rails6-action-mailbox/
Rails 5.2Ͱ͑ͦ͏???
Action Mailbox֓ཁ
Action Mailboxͱʁ • ड৴ϝʔϧʹରͯ͠ɺʮRailsʯͰɺॲཧ͢Δʂ • S3ʹอଘͨ͠Γɺ Action MailerΛͬͯɺࣗಈฦ৴ͨ͠Γ… • ฦ৴ϝʔϧΛΣϒʹࡌͤͨΓ
4FOE(SJE Ϣʔβʔ ϝʔϧૹ৴ RailsʹHTTP Post ɹ3BJMT "DUJPO.BJMCPY ॲཧ %# อଘ
4
ಋೖํ๏
ॳظઃఆ • $ rails action_mailbox:install • ApplicationMailboxΫϥε͕ੜ͞ΕΔ • MailboxΛ֨ೲ͢Δςʔϒϧ͕ੜ͞ΕΔ •
ActiveStorageಉ࣌ʹΠϯετʔϧ͞ΕΔ
༨ஊ • ActiveStorageͷMigration Version 5.2Ͱ ੜ͞ΕΔ͕ɺਖ਼͍༷͠ • https://github.com/rails/rails/pull/32042
app/mailboxes/application_mailbox.rb class ApplicationMailbox < ActionMailbox::Base #
[email protected]
Ѽͷϝʔϧ # MegurosMailboxΫϥεͰɺॲཧΛߦ͏ routing
/^meguro@/i => :meguros end
ϝʔϧɺ ActionMailbox::InboundEmail Ϟσϧͱͯ͠ѻΘΕΔ • class InboundEmail < ActiveRecord::Base • https://github.com/rails/rails/blob/
master/actionmailbox/app/models/ action_mailbox/inbound_email.rb • ActiveStorageͱࣅͨΑ͏ͳײ͡??
app/mailboxes/application_mailbox.rb • ҙ • routingʹରԠ͢ΔϝʔϧΞυϨεʹૹΔͱɺ ϝʔϧ͕delivered ѻ͍ • ରԠ͠ͳ͍ϝʔϧΞυϨεʹૹΔͱɺ bounced
ѻ͍ʹͳΔ • ྫʣ #<ActionMailbox::InboundEmail id: ..., status: "bounced", ...>]>
None
ϝʔϧαʔϏεड͚ೖΕઃఆ • config/environments/֤ڥ.rb config.action_mailbox.ingress = # ͜͜ʹαʔϏε໊ # sendgridͷ߹ config.action_mailbox.ingress
= :sendgrid # mailgunͷ߹ config.action_mailbox.ingress = :mailgun # exam, mailgun, mandrill, postfix, postmark, qmail, sendgridΛαϙʔτ͍ͯ͠Δ
ύεϫʔυઃఆ • SendGridͳͲͷϝʔϧαʔϏεͱͷ࿈ܞͰɺ ύεϫʔυ͕ٻΊΒΕΔͷͰɺ ڥม or CredentialsͰύεϫʔυΛ RailsଆͰઃఆ͓ͯ͘͠
ྫʣCredentials
ϝʔϧαʔϏεଆͷઃఆ ྫɿSendGrid SendGrid͔ΒɺHTTP POSTͯ͠Β͏ʂ https://actionmailbox:password@domain/rails/ action_mailbox/sendgrid/inbound_emails
Sender AuthenticationͷઃఆΕͣʹ ϝʔϧΛड৴͢ΔυϝΠϯʹରͯ͠ɺ DNSઃఆΛͯ͠Լ͍͞ Status͕ Verifiedʹͳ͍ͬͯͨΒɺOK
S3ͷઃఆ • Active StorageͱS3Λܨ͛Δ͚ͩͰ Action Mailboxͱউखʹ࿈ܞͯ͘͠Ε·͢ • ↓͜Μͳσʔλ͕ೖΓ·͢
σϞ
ϝʔϧΛ
[email protected]
ʹૹΔͱɺ༰͕ˣʹࡌΓ·͢ https://www.beif.jp/mailbox/megurorbs ʢ͜ͷαΠτ͙͢Ϋϩʔζ͢Δ༧ఆʣ
ิ
S3͔ΒϝʔϧϑΝΠϧΛμϯϩʔυ͢Δ͜ͱͰ Mail::MessageͷϝιουΛ͑Δ
S3͔ΒϝʔϧϑΝΠϧΛμϯϩʔυ͢Δ͜ͱͰ Mail::MessageͷϝιουΛ͑Δ • > ActionMailbox::InboundEmail.first.mail.class • D, [2019-06-25T00:41:49.319609 #4] DEBUG
-- : ActionMailbox::InboundEmail Load (1.5ms) SELECT "action_mailbox_inbound_emails".* FROM "action_mailbox_inbound_emails" ORDER BY "action_mailbox_inbound_emails"."id" ASC LIMIT $1 [["LIMIT", 1]] • D, [2019-06-25T00:41:49.348480 #4] DEBUG -- : ActiveStorage::Attachment Load (2.6ms) SELECT "active_storage_attachments".* FROM "active_storage_attachments" WHERE "active_storage_attachments"."record_id" = $1 AND "active_storage_attachments"."record_type" = $2 AND "active_storage_attachments"."name" = $3 LIMIT $4 [["record_id", 9], ["record_type", "ActionMailbox::InboundEmail"], ["name", "raw_email"], ["LIMIT", 1]] • D, [2019-06-25T00:41:49.351096 #4] DEBUG -- : ActiveStorage::Blob Load (1.5ms) SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = $1 LIMIT $2 [["id", 9], ["LIMIT", 1]] • I, [2019-06-25T00:41:50.006908 #4] INFO -- : S3 Storage (655.4ms) Downloaded file from key: hogehogehogehogehoge • => Mail::Message
ૹ৴ݩΞυϨεͳͲऔΕΔ
ૹ৴ݩΞυϨεͳͲऔΕΔ
·ͱΊ
·ͱΊ • ϝʔϧαʔϏεଆͷઃఆඞཁʹͳΔ • SendGridͳΒɺInbound ParseͳͲ • SESɺRails 6.1͔ΒͷαϙʔτͱͳΓͦ͏ •
https://github.com/rails/rails/commit/ f480cfabcd9000b5817b610e21466299025b12d2 • ࣍ճ • ࣗಈฦ৴ͱ͔ Ϣʔβʔςʔϒϧͱૹ৴͞ΕͨϝʔϧͷΞυϨεΛಥ͖߹Θͤͯɺ ͲͷϢʔβʔ͕ϝʔϧΛૹͬͨͷ͔Λ͔ΔΑ͏ʹͯ͠ΈΔ • InboundEmail͔ΒͷใऔಘΛͲΕ͚ͩͰ͖Δ͔
ऴΘΓ
ࢀߟ • Action Mailbox gem • https://github.com/rails/actionmailbox/tree/master • Rails Guides
• https://edgeguides.rubyonrails.org/ action_mailbox_basics.html • bagelee • https://bagelee.com/programming/ruby-on-rails/rails6- action-mailbox/