Class: ActionMailbox::Ingresses::Postfix::InboundEmailsController
- Inherits:
-
BaseController
- Object
- BaseController
- ActionMailbox::Ingresses::Postfix::InboundEmailsController
- Defined in:
- app/controllers/action_mailbox/ingresses/postfix/inbound_emails_controller.rb
Overview
Ingests inbound emails relayed from Postfix.
Authenticates requests using HTTP basic access authentication. The username is always 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 Postfix ingress can learn its password. You should only use the Postfix ingress over HTTPS.
Returns:
-
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 from Postfix -
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
Usage
-
Tell Action Mailbox to accept emails from Postfix:
# config/environments/production.rb config.action_mailbox.ingress = :postfix -
Generate a strong password that Action Mailbox can use to authenticate requests to the Postfix ingress.
Use
rails credentials:editto add the password to your application’s encrypted credentials underaction_mailbox.ingress_password, where Action Mailbox will automatically find it:action_mailbox: ingress_password: ...Alternatively, provide the password in the
RAILS_INBOUND_EMAIL_PASSWORDenvironment variable. -
Postfixhttps://serverfault.com/questions/258469/how-to-configure-postfix-to-pipe-all-incoming-email-to-a-script to pipe inbound emails to
bin/rails action_mailbox:ingress:postfix, providing theURLof the Postfix ingress and theINGRESS_PASSWORDyou previously generated.If your application lived at
https://example.com, the full command would look like this:URL=https://example.com/rails/action_mailbox/postfix/inbound_emails INGRESS_PASSWORD=... bin/rails action_mailbox:ingress:postfix
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
45 46 47 |
# File 'app/controllers/action_mailbox/ingresses/postfix/inbound_emails_controller.rb', line 45 def create ActionMailbox::InboundEmail. request.body.read end |