All threads / How to save ActionMailbox inbound HTML emails and attachments with ActionText and ActiveStorage Discussion

Ask A Question

Notifications

You’re not receiving notifications from this thread.

How to save ActionMailbox inbound HTML emails and attachments with ActionText and ActiveStorage Discussion

Firstly, thanks for this. It has been very useful and saved me a heck of a lot of time. I do have one specific question. In app/mailboxes/post.rb should line 11 not read:

  @_attachments ||= mail.attachments.map do |attachment|

As I read the code at the moment, the map loop in method attachments gets executed twice: once via the call to body to extract the embedded images etc and a second time directly from process. This in turn means that every attachment is saved twice in the database.

Reply

Hey Chris, Thanks for this screencast! There aren't a whole lot of Action Mailbox tutorials out there and this is one of the best.

One very minor improvement: When building ActiveStorage blobs out of attachments, you can simply use attachment.decoded instead of attachment.body.to_s, as seen in the mail readme :)

Reply
Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 37,629+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.