When implementing Sponsoring Document Incoming Management, I added a route to be able to receive attached document by email. But it has the flaw to require a specific format (raw email or JSON).
There are many services that provides hooks for inbound email like Sendgrid, Mailchimp, Postmark or Mailpace. They use a JSON format with little variation and so they can not be used with the current document incoming route.
Also they usually push all the email to a single hook but we may want to have different processes per destination addresses.
In a module named
Add a generic application route with a type as parameter (
The type define how to parse the request. By default it expect a
Provide a generic structure to represent the content of an email. This structure is used by implementation to convert for example the JSON specific format into a common one.
origin: the email address of origin
destination: the email address of destination (match any
subject: a regexp pattern on the
attachment name: a regexp pattern on the attachment names.
name: header name
value: a regexp pattern
action: a list of available processing methods (ex: document incoming). The methods receive as parameter the structured email. (same design as for
The route must support to receive a list of emails per call (as some services group them).
The module configuration is restricted to “Administration” group under the “Administration” menu.
Each module that want to support inbound email, has to extend the rule model to add its actions.
This design is not restricted to webhook providers, it can work also with for example procmail receipt (like the example in the document incoming documentation). But also using an IMAP or POP script that fetch emails periodically.