Skip to content

Instantly share code, notes, and snippets.

@adamloving
Last active December 13, 2015 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamloving/4989653 to your computer and use it in GitHub Desktop.
Save adamloving/4989653 to your computer and use it in GitHub Desktop.
Some ruby code to do a spam check of an email via http://spamcheck.postmarkapp.com/doc
#!/usr/bin/env ruby
require 'json'
f = open('test/fixtures/raw_email.txt')
s = f.read
h = { email: s, options: 'long' } # the postmarkapp format
File.open('spam-check.json', 'w') { |f| f.write(h.to_json) }
results = `curl -X POST "http://spamcheck.postmarkapp.com/filter" -H "Accept: application/json" -H "Content-Type: application/json" -v -d @spam-check.json`
results = JSON.parse(results)
puts results['report']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment