Skip to content

Latest commit

 

History

History
107 lines (77 loc) · 2.36 KB

README.md

File metadata and controls

107 lines (77 loc) · 2.36 KB

rspamd-ruby

CI Gem Version

Ruby client for Rspamd’s HTTP API

Get started

To install the latest version using Bundler:

gem "rspamd-ruby"

To manually install rspamd-ruby via Rubygems simply gem install:

gem install rspamd-ruby

If you're not using Bundler, you'll need to add require "rspamd-ruby" to your Ruby file.

Usage

Initialize a client with the host and port of an Rspamd controller process:

client = Rspamd::Client.new(host: "localhost", port: 11334)

Check a message:

result = client.check(<<~MIME)
  Date: Tue, 21 Jan 2020 21:04:42 +0000
  From: Alice <alice@example.com>
  To: Bob <bob@example.com>
  Message-ID: <975bad33-2e76-40c3-89aa-7fe1edcbe7ce@example.com>
  Subject: Hello
  Mime-Version: 1.0
  Content-Type: text/plain; charset=UTF-8
  Content-Transfer-Encoding: quoted-printable
  Delivered-To: bob@example.com

  Hi Bob!

  -Alice
MIME

result.spam? # => false
result.ham? # => true

result.score # => 1.2
result.required_score # => 15
result.action # => "no action"

Report a message as spam:

client.spam!(<<~MIME)
  Date: Tue, 21 Jan 2020 21:04:42 +0000
  From: Spammer <spammer@example.com>
  To: Bob <bob@example.com>
  Message-ID: <975bad33-2e76-40c3-89aa-7fe1edcbe7ce@example.com>
  Subject: Hello
  Mime-Version: 1.0
  Content-Type: text/plain; charset=UTF-8
  Content-Transfer-Encoding: quoted-printable
  Delivered-To: bob@example.com

  Buy some stuff?
MIME

Report a message as ham:

client.ham!(<<~MIME)
  Date: Tue, 21 Jan 2020 21:04:42 +0000
  From: Alice <alice@example.com>
  To: Bob <bob@example.com>
  Message-ID: <975bad33-2e76-40c3-89aa-7fe1edcbe7ce@example.com>
  Subject: Hello
  Mime-Version: 1.0
  Content-Type: text/plain; charset=UTF-8
  Content-Transfer-Encoding: quoted-printable
  Delivered-To: bob@example.com

  Hi Bob!

  -Alice
MIME

Acknowledgments

rspamd-ruby is MIT-licensed open-source software from 37signals, the creators of Ruby on Rails.


© 2023 37signals, LLC.