Last active
December 6, 2016 03:57
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Api::Private::BouncedEmailsController < Api::BaseController | |
def create | |
BounceMailer.receive(params[:email]) | |
head :created | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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