Ruby client for Rspamd’s HTTP API
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.
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 <[email protected]>
To: Bob <[email protected]>
Message-ID: <[email protected]>
Subject: Hello
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Delivered-To: [email protected]
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 <[email protected]>
To: Bob <[email protected]>
Message-ID: <[email protected]>
Subject: Hello
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Delivered-To: [email protected]
Buy some stuff?
MIME
Report a message as ham:
client.ham!(<<~MIME)
Date: Tue, 21 Jan 2020 21:04:42 +0000
From: Alice <[email protected]>
To: Bob <[email protected]>
Message-ID: <[email protected]>
Subject: Hello
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Delivered-To: [email protected]
Hi Bob!
-Alice
MIME
rspamd-ruby is MIT-licensed open-source software from 37signals, the creators of Ruby on Rails.
© 2023 37signals, LLC.