Introduction

Rspamd is an advanced spam filtering system supporting a variety of filtering mechanisms including regular expressions, statistical analysis and custom services such as URL black lists. Each message is analysed by rspamd and given a spam score.

According to this spam score and the user’s settings rspamd recommends an action for the MTA to apply to the message- for example to pass, reject or add a header. Rspamd is designed to process hundreds of messages per second simultaneously.

You can watch the following introduction video from FOSDEM-2016 where I describe the main features of rspamd and explain why rspamd runs so fast.

Rspamd is packaged for the major Linux distributions and is also available via FreeBSD ports and NetBSD pkgsrc.

Spam filtering features

Spam filtering features implemented in Rspamd include:

Rspamd uses a conjunction of different techniques to make a final decision about a message. This improves the overall quality of filtering and reduces the number of false positives (i.e. when a innocent message is incorrectly classified as spam). I have tried to simplify rspamd usage by adding the following elements:

Performance

Rspamd is designed to be fast. The core of rspamd is written in C and uses an event-driven model that allows for processing multiple messages simultaneously without blocking. Moreover, a set of techniques is used in rspamd to process messages faster:

Extensions

Besides its C core, rspamd provides an extensive Lua API to access almost all the features available directly from C. Lua is an extremely easy to learn programming language though it is powerful enough to implement complex mail filters. In fact rspamd has a significant amount of code written completely in Lua such as DNS blacklists checks, user’s settings or different maps implementation. You can also write your own filters and rules in Lua adapting rspamd’s functionality to your needs. Furthermore, Lua programs are very fast and their performance is rather close to pure C. However, you should note that for the most performance critical tasks you usually use the rspamd core functionality than Lua code. Anyway, you can also use LuaJIT with rspamd if your goal is maximum performance. Functionality supported by the Lua API includes:

rspamd_config.MYFILTER = function(task)
-- Do something
end

References