1 / 18

Action Mailbox - A Brand New Feature Coming To Rails 6 - BoTree Technologies

Action Mailbox is a new feature of Rails 6. It provides us a way to handle inbounds emails to our rails application by using different email platforms and APIs like Amazon SES, Postmark, Mailgun.<br>Read More - Rails 6: Action Mailboxu200au2014u200aExplained. Why? How? When?<br>https://medium.com/@sanjaywrites/action-mailbox-explained-why-how-when-af92d8708662<br>

Télécharger la présentation

Action Mailbox - A Brand New Feature Coming To Rails 6 - BoTree Technologies

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Action Mailbox A Brand New Feature Coming To Rails 6 By Tejasvini Parikh BoTree Technologies

  2. Topics • Introduction • Setup • Configuration • Routing rules • Example • Test emails with conductor

  3. Introduction What is Action Mailbox?

  4. Introduction • Action mailbox routes incoming emails to controller like mailboxes. • It ships with ingresses for Amazon SES, SendGrid(email platform), Mailgun, Mandrill and Postmark(email api). We can also handle inbound mails directly via the built-in Exim, Postfix, and Qmail ingresses(mail transfer agents). • The inbound emails are turned into InboundEmail records using Active Record and feature lifecycle tracking, storage of the original email on cloud storage via Active Storage, and responsible data handling with on-by-default incineration. • Inbound emails are routed asynchronously using Active Job to one or several dedicated mailboxes

  5. Setup • Action mailbox works with ruby 2.6 or higher versions. • Command for generating migrations. • First command will create two migrations files and application_mailbox.rb under ‘app/mailboxes’. • After ‘rails db:migrate’ it will create three tables named: ‘active_storage_blobs’, ‘active_storage_attachments’ and ‘action_mailbox_inbound_emails’. $ rails action_mailbox:install $ rails db:migrate

  6. Setup

  7. Setup

  8. Setup • We can generate new mailbox by following command: • Hurray!!! Setup is done! $ rails g mailbox mailbox_name

  9. Configuration • We need to tell Action mailbox from where it needs to accept emails. • We can do this configuration in config/environments/RAILS_ENV.rb • config.action_mailbox.ingress = :postmark • For postfix, exim, Qmail :relay • Here are different URL formats for tell email api or server that it need to forward emails to this path.

  10. Configuration bin/rails action_mailbox:ingress:exim URL=https://example.com/rails/action_mailbox/relay/inbound_emails INGRESS_PASSWORD=... • Exim: • We need to store credentials under action_mailbox.ingress_password or in RAILS_INBOUND_EMAIL_PASSWORD environment variable • Postfix: • Qmail:

  11. Configuration URL=https://example.com/rails/action_mailbox/mailgun/inbound_emails/mime • Mailgun: • We need to store credentials under action_mailbox.mailgun_api_key or in MAILGUN_INGRESS_API_KEY environment variable • Mandrill: • action_mailbox.mandrill_api_key • MANDRILL_INGRESS_API_KEY URL=https://example.com/rails/action_mailbox/mandrill/inbound_emails

  12. Configuration URL=https://actionmailbox:PASSWORD@example.com/rails/action_mailbox/postmark/inbound_emails • Postmark: • action_mailbox.ingress_password • RAILS_INBOUND_EMAIL_PASSWORD • Make sure that checkbox labeled "Include raw email content in JSON payload" is checked while configuring Postmark inbound webhook

  13. Configuration https://actionmailbox:PASSWORD@example.com/rails/action_mailbox/sendgrid/inbound_emails • Sendgrid: • action_mailbox.ingress_password • RAILS_INBOUND_EMAIL_PASSWORD • Make sure that checkbox labeled "Post the raw, full MIME message" is checked while configuring SendGrid Inbound Parse webhook.

  14. Routing Rules class ApplicationMailbox < ActionMailbox::Base # Any of the recipients of the mail (whether to, cc, bcc) are matched against the regexp. routing /^replies@/i => :replies # Any of the recipients of the mail (whether to, cc, bcc) needs to be an exact match for the string. routing "help@example.com" => :help # Any inbound_email that has not been already matched will be sent to the BackstopMailbox. routing :all => :backstop end

  15. Test Emails with conductor • to test incoming emails in development without actually sending and receiving real emails we will use a conductor controller mounted at /rails/conductor/action_mailbox/inbound_emails. • It gives you an index of all the Inbound Emails in the system, their state of processing, and a form to create a new InboundEmail as well.

  16. References https://edgeguides.rubyonrails.org/action_mailbox_basics.html https://medium.com/@sanjaywrites/action-mailbox-explained-why-how-when-af92d8708662

  17. Related Action MailboxBlog Rails 6: Action Mailbox — Explained. Why?How? When?

More Related