https://github.com/kenjij/postmark-inbound
A Ruby server for Postmark inbound webhook
https://github.com/kenjij/postmark-inbound
postmark ruby
Last synced: 8 months ago
JSON representation
A Ruby server for Postmark inbound webhook
- Host: GitHub
- URL: https://github.com/kenjij/postmark-inbound
- Owner: kenjij
- License: mit
- Created: 2016-11-21T04:58:58.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-24T00:14:52.000Z (almost 9 years ago)
- Last Synced: 2024-10-11T23:43:23.443Z (over 1 year ago)
- Topics: postmark, ruby
- Language: Ruby
- Size: 10.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# postmark-inbound
[](http://badge.fury.io/rb/postmark-inbound) [](https://codeclimate.com/github/kenjij/postmark-inbound) [](https://hakiri.io/github/kenjij/postmark-inbound/master)
A Ruby server for Postmark inbound webhook.
## Requirements
- [Ruby](https://www.ruby-lang.org/) 2.1 <=
- [Kajiki](https://kenjij.github.io/kajiki/) 1.1 <=
- [Sinatra](http://www.sinatrarb.com) 1.4 <=
## Install
```
$ gem install postmark-inbound
```
## Configure
Create a configuration file following the example below.
```ruby
# Configure application logging
PINS.logger = Logger.new(STDOUT)
PINS.logger.level = Logger::DEBUG
PINS::Config.setup do |c|
# User custom data
c.user = {my_data1: 'Something', my_data2: 'Somethingelse'}
# For security, basic auth is required.
# Set accepted passwords; username is ignored
c.passwords = [
'someSTRING1234',
'OTHERstring987'
]
# Paths of where you've stored the handlers
c.handler_paths = [
'handlers'
]
# HTTP server (Sinatra) settings
c.dump_errors = true
c.logging = true
end
```
### Handlers
Handler blocks are called for every incoming requests. Create as many files you'd like containing handlers, for example: `handlers/examples.rb`
```ruby
PINS::Handler.add do |pin|
# The 'pin' variable contains data from Postmark
break unless pin[:originalrecipient] == 'myinbox@pm.example.com'
puts "It's a match!"
# Do something more
end
# You can have multiple handlers in one file
PINS::Handler.add do |pin|
break unless pin[:spam_status]
puts "We've got a spam."
# Do something more
end
```
## Use
To see help:
```
$ pin-server -h
Usage: pin-server [options] {start|stop}
-c, --config= Load config from file
-d, --daemonize Run in the background
-l, --log= Log output to file
-P, --pid= Store PID to file
-p, --port= Use port (default: 4567)
```
The minimum to start a server:
```
$ pin-server -c config.rb start
```