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

Thanks Chris! I put this into a concern to be able to reuse it across multiple mailboxes: https://gist.github.com/sowenjub/9917305b2b551a31df9f9ed0ec34d242

Reply
Join the discussion
Create an account Log in

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

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

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