Skip to content

Comments

Add ActionMailbox#9102

Open
gbp wants to merge 16 commits intoadd-action-mailbox-prepfrom
add-action-mailbox
Open

Add ActionMailbox#9102
gbp wants to merge 16 commits intoadd-action-mailbox-prepfrom
add-action-mailbox

Conversation

@gbp
Copy link
Member

@gbp gbp commented Jan 28, 2026

Relevant issue(s)

Fixes #8801

What does this do?

Adds the ability to receive email via ActionMailbox.

Why was this needed?

Removing custom mail handling code and switching to the Rails-way

@gbp gbp force-pushed the add-action-mailbox branch 3 times, most recently from 41f6816 to 314ddff Compare February 2, 2026 16:50
@gbp gbp changed the base branch from develop to add-action-mailbox-prep February 2, 2026 16:51
@gbp gbp force-pushed the add-action-mailbox-prep branch from 975a78c to f524af8 Compare February 3, 2026 09:39
@gbp gbp force-pushed the add-action-mailbox branch from 314ddff to 604cb99 Compare February 3, 2026 09:40
@gbp gbp marked this pull request as ready for review February 3, 2026 10:23
@gbp gbp added the on-staging label Feb 10, 2026
gbp added 6 commits February 10, 2026 11:22
Integrate ActionMailbox into `RequestMailer.receive` for inbound email
handling. This maintains existing functionality but lays the groundwork
for future enhancements.

Benefits of using ActionMailbox include:

1. Enhanced email routing capabilities, enabling specialised
   processing like the Excel hidden data spreadsheet analyzer.
2. Refactoring opportunities for `RequestMailer#receive`, particularly
   for spam detection, duplicate email handling, and initial request
   assessment.
3. Clear separation of concerns between Mailers (for sending) and
   Mailboxes (for receiving).
4. Improved email processing efficiency through ActionMailbox,
   facilitating background job handling and potential simplification
   of mail ingress.
5. Provides a solution for re-users to receive emails without needing
   their own mail server setup.
Include options for ActionMailbox supported services in the retriever
method and set the ingress setting.
Instead of calling inline extract into a method so we can call later
in the install script after bundle install has been run.

This is so we can set the ingress password in the Rails credentials
needed for the ActionMailbox migration.
Set credentials and correctly configure Postfix pipe to use
ActionMailbox ingress with the correct password.
Ensure encrypted credentials and private key aren't committed into the
repo.

Normally for Rails it is acceptable for the encrypted credentials to be
committed but given Alaveteli powers multiple sites we don't want this.
@gbp gbp force-pushed the add-action-mailbox branch from 604cb99 to ad69c8c Compare February 10, 2026 11:23
gbp added 10 commits February 12, 2026 12:05
Move test to higher level allowing us rollback the fix in #5867 as this
won't been needed in the future when emails are stored in ActiveStorage
before processing.

This will allow us to use ActionMailbox's `Mail.from_source` extension.
Use `Mail.from_source` from ActionMailbox. Both method do the same thing
so this is a straight swap.

Allows us to call `#mail` on the ActionMailbox::InboundEmail instance in
the RequestMailbox.
Copy link
Member

@garethrees garethrees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, so much cleanup in all of this 🙌

See: https://github.com/mysociety/alaveteli/wiki/ActionMailbox-Migration-Guide

* _Required:_ After ActionMailbox migration please backup `config/master.key`.
This file gets generated automaticaally and is the private encryption key for
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: /automaticaally/automatically/

* _Required:_ After ActionMailbox migration please backup `config/master.key`.
This file gets generated automaticaally and is the private encryption key for
the credentials. Without it the application can't read credentials. If you
ever move servers or reinstall Alaveteli then you might need this file.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/might/will/?

Might be worth linking to the upstream rails guides here (https://guides.rubyonrails.org/security.html#custom-credentials I think is the main guide but not super familiar with this)


* _Required:_ Please update your `config/storage.yml` file to include a
production configuration for `inbound_emails`. See
`config/storage.yml-example` as an example.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to set filesystem-based as the default? I expect that will be what most start with.

end

def get_fixture_mail(filename_or_string, email_to = nil, email_from = nil)
def get_fixture_mail(filename_or_string, email_to: nil, email_from: nil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could make these just to: nil, from: nil as its fairly obvious these are about the mail headers?

content.gsub!('EMAIL_ENVELOPE_TO', kwargs[:email_envelope_to])
end
content
kwargs.slice(*%i[email_to email_from email_cc email_bcc email_envelope_to]).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly could remove the email_ prefix from the kwargs to make method calls shorter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integrate ActionMailbox

2 participants