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
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
470
Rails 6.0 Action Mailboxについて
casix
0
410
Other Decks in Technology
See All in Technology
AI時代のエンジニアの情報発信〜個人の発信を組織の力に変える〜
ryo_kawamata
0
4.8k
Adversary Infrastructure Hunting101
disconinja
0
180
AWSセキュリティで活用するAI機能
cmusudakeisuke
1
380
SLOを阻む不安
sraku2159
0
160
ビジネス部門からPOを迎えての半年間の進歩と課題
zozotech
PRO
0
170
キヨさん、67歳。AIコーディングエージェントに挑む
happysamurai294
0
130
Claude for Google Workspaces ポン出し/claude-for-google-workspace-slide-conversion
emiki
0
13k
You Have Agency(サンキュー、Ruby)
snoozer05
PRO
4
620
データマネジメント × 法務で作りあげる、 freeeの新しいデータガバナンスへの軌跡
freee
PRO
2
580
Agent 活用環境の構築・運用のための AWS サービスのご紹介/agentcore-for-building-and-operating-agents
ren8k
1
280
[re:Invent2026事前勉強会(有志開催)]続きは、ラスベガスの廊下で / continue-in-the-vegas-hallway
sh_fk2
0
430
LLMの知識とAIエージェント
happysamurai294
0
130
Featured
See All Featured
Building Adaptive Systems
keathley
44
3.3k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
340
Amusing Abliteration
ianozsvald
1
370
Docker and Python
trallard
47
4.2k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.4k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.4k
It's Worth the Effort
3n
188
29k
Thoughts on Productivity
jonyablonski
76
5.4k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.2k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
31k
Designing Experiences People Love
moore
143
24k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
390
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/