On this page
class ActionMailbox::Ingresses::Mailgun::InboundEmailsController
Ingests inbound emails from Mailgun. Requires the following parameters:
body-mime: The full RFC 822 messagetimestamp: The current time according to Mailgun as the number of seconds passed since the UNIX epochtoken: A randomly-generated, 50-character stringsignature: A hexadecimal HMAC-SHA256 of the timestamp concatenated with the token, generated using the Mailgun Signing key
Authenticates requests by validating their signatures.
Returns:
204 No Contentif an inbound email is successfully recorded and enqueued for routing to the appropriate mailbox401 Unauthorizedif the request’s signature could not be validated, or if its timestamp is more than 2 minutes old404 Not Foundif Action Mailbox is not configured to accept inbound emails from Mailgun422 Unprocessable Entityif the request is missing required parameters500 Server Errorif the Mailgun Signing key is missing, or one of the Active Record database, the Active Storage service, or the Active Job backend is misconfigured or unavailable
Usage
Give Action Mailbox your Mailgun Signing key (which you can find under Settings -> Security & Users -> API security in Mailgun) so it can authenticate requests to the Mailgun ingress.
Use
bin/rails credentials:editto add your Signing key to your application’s encrypted credentials underaction_mailbox.mailgun_signing_key, where Action Mailbox will automatically find it:action_mailbox: mailgun_signing_key: ...Alternatively, provide your Signing key in the
MAILGUN_INGRESS_SIGNING_KEYenvironment variable.Tell Action Mailbox to accept emails from Mailgun:
# config/environments/production.rb config.action_mailbox.ingress = :mailgunConfigure Mailgun to forward inbound emails to
/rails/action_mailbox/mailgun/inbound_emails/mime.If your application lived at
https://example.com, you would specify the fully-qualified URLhttps://example.com/rails/action_mailbox/mailgun/inbound_emails/mime.
Public Instance Methods
# File actionmailbox/app/controllers/action_mailbox/ingresses/mailgun/inbound_emails_controller.rb, line 49
def create
ActionMailbox::InboundEmail.create_and_extract_message_id! mail
end
© 2004–2021 David Heinemeier Hansson
Licensed under the MIT License.