Receiving Support Emails with Action Mailbox
Learn to set up an action mailbox to send and receive order confirmation emails.
Configuring Rails to receive emails requires three steps. We have to first set up Action Mailbox, set up Active Storage to hold the raw emails we receive, and implement a mailbox, which is like a controller that handles incoming emails.
Setting up action Mailbox
To set up Action Mailbox in our app, we’ll run a Rake task. This will create some configuration files, a base mailbox class we’ll inherit from, and some database tables that Rails will use to store information about incoming emails. Let’s run the Rake task:
bin/rails action_mailbox:install
Note that
a) We’ve reformatted our output to fit the pages in the course and
b) Because there were two migrations created and migration filenames have a date and timestamp in them, your filenames won’t exactly match ours.
Next, we’ll add the tables that the Rake task created to our development and test databases:
bin/rails db:migrate
A live terminal
You can run the above commands using the terminal provided below:
In the real world, we’d also need to configure Action Mailbox for our particular incoming email service provider. The Rails Guide is the best place to look for how to do that. We won’t set one up here since setting up accounts with services like Amazon SES or Mailgun is somewhat involved. Once an account is ...