Karta. Scan. Rspamd
(Karta v1.0.0)
Spam scanning of a received message through rspamd's HTTP API
(POST /checkv2), before the final reply to DATA.
The message is streamed to rspamd from the spool file, never read
into memory: a message of any size Karta accepts costs one chunk of
memory here. The envelope goes as rspamd's own request headers (its
Ip, Helo, From and Rcpt), and each one is left out when it is
not a plain printable value, so nothing a client wrote can start a
header line. The answer is read up to :max_body bytes; a longer one is
cut off and fails to parse, which is a scan failure, not a partial
result.
check/2 returns what rspamd said, in the small shape Karta keeps:
{:ok, %{score: 6.5, required_score: 15.0, action: "add header",
symbols: [%{name: "GTUBE", score: 15.0, description: "..."}]}}symbols are the symbols with a score, highest first, at most 50; names
that are not letters, digits, _, . and - are dropped and
descriptions are cut to 200 characters with their control characters
replaced. action is one of rspamd's actions, or "unknown" when
rspamd names another: it is never passed on as text. {:error, reason}
is a scanner that could not answer (:timeout, :econnrefused,
{:status, 500}, :invalid_answer, :too_large, ...).
Options: :url (required; http or https), :password (rspamd's
controller password, optional), :envelope (%{ip:, helo:, mail_from:, rcpt:}), :timeout (milliseconds for the connection and each read),
:max_size (bytes; a larger message is not sent) and :max_body.
Summary
Functions
Scans the message at path. See the module doc.