[Feature proposal] ActionMailbox storage service configuration

There are cases when using “main” storage service for storing emails is undesirable – to name a few, regulatory compliance and ease of batch management of email uploads.

I propose that ActionMailbox can be configured to use a separate ActiveStorage service.

I’ve prepared a PR doing just that for your reference Problem: ActionMailbox uses default ActiveStorage service by yrashk · Pull Request #42634 · rails/rails · GitHub

Please let me know if you have any thoughts or questions.


This looks like a good idea but I need to think about it some more. I’m wondering if it wasn’t configurable before how did people deal with this in production? Were they just overriding the behavior somehow?

I’m currently overriding it in production and I seriously dislike that.


@yrashk That’s a good point, but even existing users will have this problem until they can upgrade to a version of Rails that has your feature. Would you be willing to share your solution for those who can’t yet?

Absolutely; it’s a hack and is likely not as robust as the PR I submitted, but I’ll extract it when I’ll be in front my computer.

This is what I’ve done for production environment so far. It produces an overloading warning (obviously) and doesn’t patch everything the PR does, but it does work in production right now.

  ActiveSupport.on_load(:action_mailbox_inbound_email) do
    ActionMailbox::InboundEmail.class_eval do
      has_one_attached :raw_email, service: :email_storage

I also had to move whatever email files I had from the original bucket to the new buckets and update the blobs table to refer to the new service name for those.

1 Like

Did you end up writing a migration for this or doing it by hand?

I did it by hand in this case. Thought of doing this in a migration, but was too lazy.

One has to consider actual data moving procedures for their case, too.