No commit activity in last 3 years
No release in over 3 years
Takes a raw email and fetches the spamassassin score and report. No dependencies outside of ruby's standard libraries.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.10
~> 10.0
 Project Readme

Postmark::SpamCheck

This is a simple client for http://spamcheck.postmarkapp.com/

I wrote it because the one that is available has a number of dependencies that I didn't want and is getting old. This library only uses the Ruby standard library.

Installation

Add this line to your application's Gemfile:

gem 'postmark-spam_check'

And then execute:

$ bundle

Or install it yourself as:

$ gem install postmark-spam_check

Usage

Give it a raw email and an optional format and timeout.

Postmark::SpamCheck.check(raw_email, report_format = :long, timeout = 60)

You can get a raw email by calling #to_s on a Mail object.

mail = Mail.new do
  from     "bill.lumbergh@example.net"
  to       "peter.gibbons@example.com"
  subject  "TPS reports"
  body     "Peter, What's happening? Yeah, about those TPS reports. Did you get the memo?"
end

Postmark::SpamCheck.check(mail.to_s)

=> #<Postmark::SpamCheck::Report:0x007fd61e189970
 @details=
  [{:points=>-0.0, :rule=>"NO_RELAYS", :description=>"Informational: message was not relayed via SMTP"},
   {:points=>-0.0, :rule=>"NO_RECEIVED", :description=>"Informational: message has no Received headers"}],
 @email=
  "Date: Mon, 19 Oct 2015 16:50:00 -0700\r\nFrom: bill.lumbergh@example.net\r\nTo: peter.gibbons@example.com\r\nMessage-ID: <562581a848336_c663feb09065bec23540@venus.local.mail>\r\nSubject: TPS reports\r\nMime-Version: 1.0\r\nContent-Type: text/plain;\r\n charset=UTF-8\r\nContent-Transfer-Encoding: 7bit\r\n\r\nPeter, What's happening? Yeah, about those TPS reports. Did you get the memo?",
 @error=nil,
 @score="-0.0">

If you don't want the details, call with :short format instead. This will only fetch the score.

Postmark::SpamCheck.check(mail.to_s, :short)

=> #<Postmark::SpamCheck::Report:0x007fd61e080088
 @details=[],
 @email=
  "Date: Mon, 19 Oct 2015 16:50:00 -0700\r\nFrom: bill.lumbergh@example.net\r\nTo: peter.gibbons@example.com\r\nMessage-ID: <562581a848336_c663feb09065bec23540@venus.local.mail>\r\nSubject: TPS reports\r\nMime-Version: 1.0\r\nContent-Type: text/plain;\r\n charset=UTF-8\r\nContent-Transfer-Encoding: 7bit\r\n\r\nPeter, What's happening? Yeah, about those TPS reports. Did you get the memo?",
 @error=nil,
 @score="0.0">

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/bradpauly/postmark-spam_check. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.