Sha256: 14b59983372ee9f0d030431b475da44f1130c3ded04f491f50cb63f1a8de93ff

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

# Ruby client for Rspamd’s HTTP API

## Usage

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

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

Check a message:

```ruby
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:

```ruby
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:

```ruby
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
```

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspamd-ruby-1.0.0 README.md