No commit activity in last 3 years
No release in over 3 years
A programable Ruby server for Postmark inbound webhook. For example, trigger notifications or automated response.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 1.1
~> 1.4
 Project Readme

postmark-inbound

Gem Version Code Climate security

A Ruby server for Postmark inbound webhook.

Requirements

Install

$ gem install postmark-inbound

Configure

Create a configuration file following the example below.

# 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

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=<s>     Load config from file
  -d, --daemonize      Run in the background
  -l, --log=<s>        Log output to file
  -P, --pid=<s>        Store PID to file
  -p, --port=<i>       Use port (default: 4567)

The minimum to start a server:

$ pin-server -c config.rb start