An Rspamd ruby client.
Add this line to your application's Gemfile:
gem 'rspamd'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install rspamd
The client will try to use the ENV['RSPAMD_URL'] environment variable. If it doesn't find one it will use http://localhost:11334
Headers | Description |
---|---|
Deliver-To | Defines actual delivery recipient of message. Can be used for personalized statistics and for user specific options |
IP | Defines IP from which this message is received |
Helo | Defines SMTP helo |
Hostname | Defines resolved hostname |
Flags | Supported from version 2.0: Defines output flags as a commas separated list |
From | Defines SMTP mail from command data |
Queue-Id | Defines SMTP queue id for message (can be used instead of message id in logging) |
Raw | If set to yes, then Rspamd assumes that the content is not MIME and treat it as raw data |
Rcpt | Defines SMTP recipient (there may be several Rcpt headers) |
Pass | If this header has all value, all filters would be checked for this message |
Subject | Defines subject of message (is used for non-mime messages) |
User | Defines username for authenticated SMTP client |
Message-Length | Defines the length of message excluding the control block |
Settings-ID | Defines settings id to apply |
Settings | Defines list of rules (settings apply part) as raw json block to apply |
User-Agent | Defines user agent (special processing if it is rspamc) |
MTA-Tag | MTA defined tag (can be used in settings) |
MTA-Name | Defines MTA name, used in Authentication-Results routines |
TLS-Cipher | Defines TLS cipher name |
TLS-Version | Defines TLS version |
TLS-Cert-Issuer | Defines Cert issuer, can be used in conjunction with client_ca_name in proxy worker |
URL-Format | Supported from version 1.9: return all URLs and email if this header is extended |
Filename |
Flags | Description |
---|---|
pass_all | pass all filters |
groups | return symbols groups |
zstd | compressed input/output |
no_log | do not log task |
milter | apply milter protocol related hacks |
profile | profile performance for this task |
body_block | accept rewritten body as a separate part of reply |
ext_urls | extended urls information |
skip | skip all filters processing |
skip_process | skip mime parsing/processing |
The email parameter is the email we want to perform scans on.
The **options is where we can set the HTTP Headers and HTTP Query String, every key/value passed into the options parmameter will be sent as Headers. To set HTTP Query Parameters, we can pass in params:String to the options.
email = 'bad_email'
reply = Rspamd.scan(email, Rcpt: 'test@test.com', params: 'bad=param')
puts reply
puts reply.total_score
puts reply.total_metric_score
Response:
<class Reply
is_skipped=false,
score=11.9,
required_score=12.0,
action="quarantine",
symbols=[
<class Reply::Symbol
name="MIME_TRACE",
score=0.0,
metric_score=0.0,
description=nil,
options=["0:+"]>
],
messages={},
message_id="undef",
time_real=0.299173,
milter={"remove_headers"=>{"X-Spam"=>0}}>
email = 'bad_email'
reply = Rspamd.fuzzy_add(email)
email = 'bad_email'
reply = Rspamd.fuzzy_del(email)
email = 'bad_email'
reply = Rspamd.learn_spam(email)
email = 'bad_email'
reply = Rspamd.learn_ham(email)
reply = Rspamd.errors()
reply = Rspamd.stat()
reply = Rspamd.stat_reset()
type = 'special_type'
reply = Rspamd.graph(type)
reply = Rspamd.history()
reply = Rspamd.history_reset()
reply = Rspamd.actions()
reply = Rspamd.symbols()
reply = Rspamd.maps()
reply = Rspamd.neighbors()
reply = Rspamd.get_map()
reply = Rspamd.fuzzy_del_hash()
reply = Rspamd.plugins()
reply = Rspamd.ping()