Skip to content

Rspamd vs SpamAssassin — when to pick which, and how to deploy Rspamd

Deploy Rspamd as a Postfix milter for high-throughput spam scoring, compare it operationally to SpamAssassin, and decide which fits the volume and operator skill profile.

Rspamd is the modern alternative to SpamAssassin — written in C with Lua extensions, an order of magnitude faster, a built-in web UI, and integrated DNS resolver. This article is the decision framework we apply when a client asks “what should we run for spam?” plus a deploy recipe for the option we recommend most of the time. The SpamAssassin counterpart is at spamassassin-deploy-postfix.

How to verify

If either engine is already installed, check what’s running and what’s scoring today.

dpkg -l | grep -E 'rspamd|spamassassin'
systemctl is-active rspamd spamassassin
ss -ltnp | grep -E ':(11332|11333|11334|783)\b'
sudo rspamc stat 2>/dev/null | head -30
sudo rspamadm configdump | head -50

The Rspamd controller listens on 11334 with a web UI; the redis backend it talks to is 6379. SpamAssassin’s spamd listens on 783. Different ports, different mental models.

What’s happening — comparison at a glance

DimensionSpamAssassinRspamd
LanguagePerl daemonC with embedded Lua
Throughput~50-200 msg/s per worker~500-2000 msg/s per worker
Bayes storageBerkeley DB / SQLRedis (mandatory)
Rules format.cf filesLua + UCL
DNS resolveruses libc resolverevent-driven internal resolver
Web UInone (mailwatch / spamassassin-helper)built-in at port 11334
Integration with Postfixcontent filter (spamc) or miltermilter (preferred)
Operator learning curvegentle — well-documentedsteeper — Lua, UCL, modules ecosystem
Memory~50-150 MB per worker~100-300 MB per worker
DKIM signingexternal (OpenDKIM)built-in dkim_signing module

The big shifts when you move from SpamAssassin to Rspamd: configuration is in UCL (a JSON/Nginx hybrid) inside /etc/rspamd/local.d/; rules are Lua and live in modules; the Bayes classifier requires Redis (the bonus is per-user statistics for free); and there is a real web UI that shows the score breakdown of any recent message — invaluable when a user asks “why was this in junk?”

The decision

Pick SpamAssassin when:

  • Volume is low (under ~20k msg/day per box).
  • The operator already knows the SA rule syntax.
  • You don’t want to run Redis just for spam stats.
  • Integration with a legacy amavis/MailScanner pipeline is in place.

Pick Rspamd when:

  • Volume is high (>20k msg/day) or growth is expected.
  • You want a UI to investigate per-message decisions.
  • You’re standing up a new mail edge from scratch.
  • You want DKIM signing in the same daemon (skip OpenDKIM entirely).
  • You’re running multi-tenant and want per-user Bayes without DB hassle.

For new installs we default to Rspamd. The rest of this article is the deploy.

The procedure (Rspamd)

  1. Install Rspamd and Redis. Rspamd’s package depends on Redis; install both from the official Rspamd APT repo for the current version:

    curl -fsSL https://rspamd.com/apt-stable/gpg.key | \
        sudo gpg --dearmor -o /usr/share/keyrings/rspamd.gpg
    echo "deb [signed-by=/usr/share/keyrings/rspamd.gpg] http://rspamd.com/apt-stable/ $(lsb_release -cs) main" | \
        sudo tee /etc/apt/sources.list.d/rspamd.list
    sudo apt update
    sudo apt install -y rspamd redis-server
    sudo systemctl enable --now redis-server rspamd
  2. Set a password for the controller UI. The Rspamd web UI sits at port 11334; without auth it will refuse to load. Generate an encrypted password hash:

    rspamadm pw
    # Enter passphrase: ...
    # $2$abc...   (paste this into the config)

    Then /etc/rspamd/local.d/worker-controller.inc:

    bind_socket = "*:11334";
    password = "$2$abc...long-hash...";
    secure_ip = "127.0.0.1";
  3. Wire the milter to Postfix. Edit /etc/postfix/main.cf to add Rspamd’s milter socket (typically port 11332 over TCP, or a UNIX socket):

    smtpd_milters = inet:127.0.0.1:11332
    non_smtpd_milters = $smtpd_milters
    milter_protocol = 6
    milter_default_action = accept
    milter_mail_macros = i {mail_addr} {client_addr} {client_name} {auth_type} {auth_authen}

    If you already have OpenDKIM/OpenDMARC, decide: either keep them and disable Rspamd’s overlapping modules (dkim_signing, dkim, dmarc, spf), or remove them and let Rspamd do everything. We prefer the latter for new deploys — fewer moving parts.

  4. Configure the action thresholds. Rspamd uses named actions, not a single threshold. Edit /etc/rspamd/local.d/actions.conf:

    reject = 15;
    add_header = 6;
    greylist = 4;
    • score < 4: clean, deliver.
    • 4 ≤ score < 6: greylist (defer once with 450).
    • 6 ≤ score < 15: add X-Spam: Yes header, deliver to Junk.
    • score ≥ 15: reject at SMTP time with 550 Message rejected as spam.

    Tune to taste. We default to the values above; an enterprise tenant with high tolerance for false positives can move reject to 12.

  5. Enable DKIM signing if removing OpenDKIM. Drop OpenDKIM and use Rspamd’s dkim_signing module — /etc/rspamd/local.d/dkim_signing.conf:

    selector = "sh2026q2";
    path = "/var/lib/rspamd/dkim/$domain.$selector.key";
    allow_username_mismatch = true;
    sign_authenticated = true;

    Generate the key and publish the DNS record the same way as in opendkim-signing-postfix, but put the key file at the path Rspamd expects:

    sudo mkdir -p /var/lib/rspamd/dkim
    sudo rspamadm dkim_keygen -d example.com -s sh2026q2 \
        -k /var/lib/rspamd/dkim/example.com.sh2026q2.key \
        > /var/lib/rspamd/dkim/example.com.sh2026q2.pub
    sudo chown -R _rspamd:_rspamd /var/lib/rspamd/dkim
    sudo chmod 600 /var/lib/rspamd/dkim/*.key
    cat /var/lib/rspamd/dkim/example.com.sh2026q2.pub
    # publish the printed TXT record at sh2026q2._domainkey.example.com
  6. Wire Bayes to Redis. /etc/rspamd/local.d/classifier-bayes.conf:

    backend = "redis";
    servers = "127.0.0.1:6379";
    autolearn = true;
    new_schema = true;

    Per-user statistics are an option; for a single-tenant box leave that default.

  7. Reload, send a probe, view in the UI. Reload Postfix and restart Rspamd:

    sudo systemctl restart rspamd
    sudo systemctl reload postfix
    echo "XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X" \
      | mail -s "gtube probe" your-mailbox@example.com

    Browse to http://mx1.example.com:11334, log in with the password from step 2, and view the History tab. The GTUBE probe should appear with a reject action and an explanation of which symbols fired.

Operational notes

  • The Rspamd web UI is a real attack surface; it lives on a TCP port. Bind it to localhost and front it with an authenticated HAProxy/Nginx, or restrict by firewall to the operator subnet. We never expose 11334 directly to the internet.
  • Bayes in Redis is the only place per-message learning lives — back Redis up (redis-cli SAVE + filesystem snapshot) on the same cadence as the rest of the mail server.
  • Rspamd has many modules; the default ones are sensible but a few (e.g. phishing, surbl, fuzzy_check) do heavy DNS lookups. Tune dns.timeout in /etc/rspamd/local.d/options.inc to prevent per-message latency spikes when a public RBL is slow.
  • The rmilter legacy package is deprecated — the integration is via Rspamd’s built-in milter worker (port 11332 by default). Don’t install rmilter.
  • Migration from SpamAssassin is not just a swap — Bayes databases don’t interchange; you have to retrain Rspamd’s Bayes from scratch on the existing ham/spam corpus.

Stack Harbor stands up Rspamd as the default scoring engine for new mail edges in the engagements we run — milter wired, Bayes in Redis, UI behind an authenticated proxy, DKIM signing folded in. The migration from a legacy SpamAssassin box is a project we deliver under our Managed Operations practice.