Skip to content

Instantly share code, notes, and snippets.

@mreinsch
Last active December 6, 2016 03:57
Show Gist options
  • Save mreinsch/6102712 to your computer and use it in GitHub Desktop.
Save mreinsch/6102712 to your computer and use it in GitHub Desktop.
relaying email from Postfix to a Rails application, using normal HTTP API endpoints
doorkeeper_contact: |"/srv/doorkeeper/current/script/email_handler contact_emails production"
doorkeeper_event_signup: |"/srv/doorkeeper/current/script/email_handler signup_emails production"
doorkeeper_bounce: |"/srv/doorkeeper/current/script/email_handler bounced_emails production"
class Api::Private::BouncedEmailsController < Api::BaseController
def create
BounceMailer.receive(params[:email])
head :created
end
end
#!/bin/bash
if [ "$2" == "production" ]; then
base_url="http://api.doorkeeper.jp"
elif [ "$2" == "development" ]; then
base_url="http://api.checkin.dev"
else
echo "4.3.5 configuration error"
exit 1
fi
/usr/bin/curl -F email='<-' -s -f $base_url/private/$1
rc=$?
if [ $rc != 0 ] ; then
echo "4.3.2 couldn't deliver message to API endpoint, code $rc"
exit 1
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment