nomad
nomad

Reputation: 65

Rails ActionMailBox: 422 Unprocessable Entity "Service name can't be blank"

I am trying to setup RailsAction Mailbox to deliver inbound emails but when I go to send the request I am getting failure. Here is the error from logs:

13:39:20 web.1  | Started POST "/rails/conductor/action_mailbox/inbound_emails" for 
::1 at 2022-07-02 13:39:20 -0400
13:39:20 web.1  |   ActiveRecord::SchemaMigration Pluck (2.1ms)  SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
13:39:20 web.1  | Processing by Rails::Conductor::ActionMailbox::InboundEmailsController#create as HTML
13:39:20 web.1  |   Parameters: {"utf8"=>"✓", "authenticity_token"=>"asdfads", "mail"=>{"from"=>"[email protected]", "to"=>"[email protected]", "cc"=>"", "bcc"=>"", "x_original_to"=>"", "in_reply_to"=>"", "subject"=>"test", "body"=>"test"}, "commit"=>"Deliver inbound email"}
13:39:20 web.1  | Completed 422 Unprocessable Entity in 53ms (ActiveRecord: 21.3ms | Allocations: 43704)
13:39:20 web.1  | 
13:39:20 web.1  | 
13:39:20 web.1  |   
13:39:20 web.1  | ActiveRecord::RecordInvalid (Validation failed: Service name can't be blank):
13:39:20 web.1  |   
13:39:20 web.1  | activerecord (7.0.0) lib/active_record/validations.rb:80:in `raise_validation_error'
13:39:20 web.1  | activerecord (7.0.0) lib/active_record/validations.rb:53:in `save!'

I have followed the steps from the docs https://guides.rubyonrails.org/action_mailbox_basics.html and here https://dev.to/truemark/setup-action-mailbox-with-sendgrid-490k to try and get this working. It failed with attachment error so I upgrade it to rails 7 and now getting this error above.

Setup action mailbox

$ rails action_mailbox:install
$ rails db:migrate

Add Mailgun Configurations

# config/environments/development.rb & config/environments/production.rb
config.action_mailbox.ingress = :mailgun

Setup Signing Key

Use bin/rails credentials:edit

action_mailbox:
    mailgun_signing_key: XXX

Setup Mailbox

$ bin/rails generate mailbox forwards

# app/mailboxes/forwards_mailbox.rb
class ForwardsMailbox < ApplicationMailbox
  def process
    byebug
  end
end

Accept Incoming Emails

 # app/mailboxes/application_mailbox.rb
 class ApplicationMailbox < ActionMailbox::Base
   routing :all => :forwards
 end

Run rails server test it out but it fails

Upvotes: 1

Views: 293

Answers (1)

fig
fig

Reputation: 31

You do not have an ActiveStorage service set.

ActionMailbox depends on ActiveStorage to save inbound mail. Ensure ActiveStorage is set up correctly to use Actionailbox.

Upvotes: 1

Related Questions