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
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
作り直せるコードは迅速に 作り直せないDBは慎重に - AI時代のプロダクトエンジニアが「判断の不可逆性」で開発速度を変える話
kinosuke01
0
260
【Oracle AI Spotlight ウェビナー】AWSか、Azureか、Google Cloudか。その議論にオラクルを含める意義。
oracle4engineer
PRO
2
240
AI時代におけるプロダクト横断勉強会の設計
zozotech
PRO
0
160
Oracle Cloud Infrastructure IaaS 新機能アップデート 2026/6 - 2026/8
oracle4engineer
PRO
0
110
AI-DLCって実際どう? 〜聞きたいこと全部聞いてみる〜
news_it_enj
0
240
いま、生成AIにKaggleをどこまで 任せられるか — ROGIIコンペでの進め方とTips
k951286
3
1.4k
全員がプロダクトへ向き合う組織を持続成長させるために——組織づくりのフライホイールと4象限 / The Flywheel Model and Four Quadrants for Organizational Design
hiro_torii
3
880
PM領域でのAI Agentの活用
lycorptech_jp
PRO
0
270
推論の観測、できていますか? 〜 Google Cloud Gemini Enterprise Agent Platformで 3つの Gemini モデルを実測して踏んだ、評価の罠 〜
shukob
PRO
0
160
AI時代に、プロダクトの数だけ積み上がる所有コストをどうエンジニアリングするか / Engineering the Cost of Ownership
kzkmaeda
0
1k
生成AIのテナント制御とシャドーMCP対策 | AIを"止めずに"、情報を守る
yukun
0
120
bet_ai_day_2026_session02
agenticsec
1
1.3k
Featured
See All Featured
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
290
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
230
How Software Deployment tools have changed in the past 20 years
geshan
1
34k
A Modern Web Designer's Workflow
chriscoyier
698
190k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.7k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
520
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
560
Context Engineering - Making Every Token Count
addyosmani
9
1.1k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
430
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
What's in a price? How to price your products and services
michaelherold
247
13k
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/