Ingests inbound emails relayed from an SMTP server.
Authenticates requests using HTTP basic access authentication. The username
actionmailbox, and the password is read from the
application's encrypted credentials or an environment variable. See the
Usage section below.
Note that basic authentication is insecure over unencrypted HTTP. An attacker that intercepts cleartext requests to the ingress can learn its password. You should only use this ingress over HTTPS.
204 No Contentif an inbound email is successfully recorded and enqueued for routing to the appropriate mailbox
401 Unauthorizedif the request could not be authenticated
404 Not Foundif Action Mailbox is not configured to accept inbound emails relayed from an SMTP server
415 Unsupported Media Typeif the request does not contain an RFC 822 message
500 Server Errorif the ingress password is not configured, or if one of the Active Record database, the Active Storage service, or the Active Job backend is misconfigured or unavailable
Tell Action Mailbox to accept emails from an SMTP relay:
# config/environments/production.rb config.action_mailbox.ingress = :relay
Generate a strong password that Action Mailbox can use to authenticate requests to the ingress.
rails credentials:editto add the password to your application's encrypted credentials under
action_mailbox.ingress_password, where Action Mailbox will automatically find it:
action_mailbox: ingress_password: ...
Alternatively, provide the password in the
Configure your SMTP server to pipe inbound emails to the appropriate ingress command, providing the
URLof the relay ingress and the
INGRESS_PASSWORDyou previously generated.
If your application lives at
https://example.com, you would configure the Postfix SMTP server to pipe inbound emails to the following command:
bin/rails action_mailbox:ingress:postfix URL=https://example.com/rails/action_mailbox/postfix/inbound_emails INGRESS_PASSWORD=...
Built-in ingress commands are available for these popular SMTP servers:
Exim (<tt>bin/rails action_mailbox:ingress:exim)
Postfix (<tt>bin/rails action_mailbox:ingress:postfix)
Qmail (<tt>bin/rails action_mailbox:ingress:qmail)
# File actionmailbox/app/controllers/action_mailbox/ingresses/relay/inbound_emails_controller.rb, line 54 def create ActionMailbox::InboundEmail.create_and_extract_message_id! request.body.read end