Closed svoop closed 5 years ago
Mailgun parses emails and sends them as JSON payload via a webhook. Unfortunately, Brimir heavily relies on parsing a raw email and (since the EML export feature) also stores the raw message which would not be available via Mailgun. Furthermore, refactoring the way post-mail
is handled (e.g. by creating an IncomingMailService which uses the Rails mailers to parse) is too big a task for me right now.
I'm therefore taking a simpler, yet less cool approach: When Mailgun receives a mail, it can be stored. The webhook then holds the API URL to fetch the mail which is available as raw MIME body as well. This can be fed into the same pipeline as post-mail
. The upsides: Way less code to touch and EML export works. The downsides: The Mailgun API key has to be configured in Brimir's secrets.yml
and one more point of failure (the REST call to Mailgun).
Here's the PR: #443
:warning: WARNING :warning:
The URL for the mail hooks had to be changed in order to accomodate other mail providers. This commit thus breaks things for those already using the post-mail
script. However, the change needed is no biggie at all and mentioned in the CHANGELOG:
First find out the mail key which protects the mail hook:
rake secret:mail_key
Then update the aliases
file of your MTA from the old to the new hook URL (replace {MAIL_KEY}
with the output from above):
OLD: http://yoururl.com/tickets.json
NEW: http://yoururl.com/post_mail/{MAIL_KEY}/tickets.json
I'm currently refactoring the way tickets are update by email. The
post-mail
script will be one way to do things, I'll implement Mailgun as another (since that's what I currently use). Adding more providers is as easy as updating the route constraints and adding one method to theTicketsController
.To secure these hooks a little, a key (derived from the base secret) will be required, which means that for existing users of
post-mail
, these are breaking changes. The update, however, will be dead simple, only the URL in the MTA'saliases
file needs to be changed. Details will follow here as well as in the CHANGELOG and README.PR should be ready later this week.