• Practical Use Cases. • Sending inbound emails to your application. • How inbound emails are processed. • Tips for deploying and running in production.
emails to controller-like mailboxes for processing in Rails. The inbound emails are turned into `InboundEmail` records using Active Record and feature life cycle tracking These inbound emails are routed asynchronously using Active Job to one or several dedicated mailboxes, which are capable of interacting directly with the rest of your domain model.
be set by default (that happens in the Application Controller). You have to set this the same way you set it for your emails. • You probably want to set up an ActiveStorage service besides ‘disk’. That can cause some issues. • Routing all your inbound email through a subdomain like inbound.yourapp.com can save a lot of headaches. ([email protected])
ApplicationMailbox def process CatFactsMailer.with(email: mail.from.first, cat_fact: cat_fact).cat_fact.deliver end def cat_fact @cat_fact ||= HTTParty.get("https://catfact.ninja/ fact").dig("fact") end end
process response = HTTParty.get(agify_url, { query: { name: name } }) age = response["age"] GuessMyAgeMailer.with(guess: age, sender_email: mail.from.first, name: name).response.deliver_now end def name mail[:from].display_names.first.presence || mail.from.first.split("@").first end end