Ruby client for Rspamd’s HTTP API
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("Date: Tue, 21 Jan 2020 21:04:42 +0000\nFrom: Alice <[email protected]>\nTo: Bob <[email protected]>\nMessage-ID: <[email protected]>\nSubject: Hello\nMime-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: quoted-printable\nDelivered-To: [email protected]\n\nHi Bob!\n\n-Alice\n")
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!("Date: Tue, 21 Jan 2020 21:04:42 +0000\nFrom: Spammer <[email protected]>\nTo: Bob <[email protected]>\nMessage-ID: <[email protected]>\nSubject: Hello\nMime-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: quoted-printable\nDelivered-To: [email protected]\n\nBuy some stuff?\n")
Report a message as ham:
client.ham!("Date: Tue, 21 Jan 2020 21:04:42 +0000\nFrom: Alice <[email protected]>\nTo: Bob <[email protected]>\nMessage-ID: <[email protected]>\nSubject: Hello\nMime-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: quoted-printable\nDelivered-To: [email protected]\n\nHi Bob!\n\n-Alice\n")