| 1 | # filter-rspamd |
| 2 | |
| 3 | ## Description |
| 4 | This filter implements the Rspamd protocol and allows OpenSMTPD to request an Rspamd analysis |
| 5 | of an SMTP transaction before a message is committed to queue. |
| 6 | |
| 7 | |
| 8 | ## Features |
| 9 | The filter currently supports: |
| 10 | |
| 11 | - greylisting |
| 12 | - adding X-Spam related headers to a message |
| 13 | - rewriting Subject |
| 14 | - DKIM-signing message |
| 15 | - Rspamd-provided SMTP replies |
| 16 | - Allow Rspamd to add and remove headers |
| 17 | |
| 18 | |
| 19 | ## Dependencies |
| 20 | The filter is written in Golang and doesn't have any dependencies beyond the Go extended standard library. |
| 21 | |
| 22 | It requires OpenSMTPD 6.6.0 or higher. |
| 23 | |
| 24 | |
| 25 | ## How to install |
| 26 | Install from your operating system's preferred package manager if available. |
| 27 | On OpenBSD: |
| 28 | ``` |
| 29 | $ doas pkg_add opensmtpd-filter-rspamd |
| 30 | quirks-3.167 signed on 2019-08-11T14:18:58Z |
| 31 | opensmtpd-filter-rspamd-0.1.x: ok |
| 32 | $ |
| 33 | ``` |
| 34 | |
| 35 | Install using Go: |
| 36 | ``` |
| 37 | $ GO111MODULE=on go get github.com/poolpOrg/filter-rspamd |
| 38 | $ doas install -m 0555 ~/go/bin/filter-rspamd /usr/local/libexec/smtpd/filter-rspamd |
| 39 | ``` |
| 40 | |
| 41 | Alternatively, clone the repository, build and install the filter: |
| 42 | ``` |
| 43 | $ cd filter-rspamd/ |
| 44 | $ go build |
| 45 | $ doas install -m 0555 filter-rspamd /usr/local/libexec/smtpd/filter-rspamd |
| 46 | ``` |
| 47 | |
| 48 | On Ubuntu the directory to install to is different: |
| 49 | ``` |
| 50 | $ sudo install -m 0555 filter-rspamd /usr/libexec/opensmtpd/filter-rspamd |
| 51 | ``` |
| 52 | |
| 53 | |
| 54 | ## How to configure |
| 55 | The filter itself requires no configuration. |
| 56 | |
| 57 | It must be declared in smtpd.conf and attached to a listener for sessions to go through rspamd: |
| 58 | ``` |
| 59 | filter "rspamd" proc-exec "filter-rspamd" |
| 60 | |
| 61 | listen on all filter "rspamd" |
| 62 | ``` |
| 63 | |
| 64 | A remote rspamd instance can be specified by providing the -url parameter to the filter: |
| 65 | ``` |
| 66 | filter "rspamd" proc-exec "filter-rspamd -url http://example.org:11333" |
| 67 | |
| 68 | listen on all filter "rspamd" |
| 69 | ``` |
| 70 | |
| 71 | Optionally a `-settings-id` parameter can be used to select a specific rspamd |
| 72 | setting. One usecase is for example to apply different rspamd rules to incoming |
| 73 | and outgoing emails: |
| 74 | |
| 75 | ``` |
| 76 | filter "rspamd-incoming" proc-exec "filter-rspamd" |
| 77 | filter "rspamd-outgoing" proc-exec "filter-rspamd -settings-id outgoing" |
| 78 | |
| 79 | listen on all filter "rspamd-incoming" |
| 80 | listen on all port submission filter "rspamd-outgoing" |
| 81 | ``` |
| 82 | |
| 83 | And in `rspamd/local.d/settings.conf`: |
| 84 | |
| 85 | ``` |
| 86 | outgoing { |
| 87 | id = "outgoing"; |
| 88 | apply { |
| 89 | groups_enabled = ["dkim"]; |
| 90 | actions { |
| 91 | reject = 100.0; |
| 92 | greylist = 100.0; |
| 93 | "add header" = 100.0; |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | ``` |
| 98 | |
| 99 | Every email passed through the `rspamd-outgoing` filter will use the rspamd `outgoing` rule instead of the default rule. |
| 100 | |
| 101 | Any configuration with regard to thresholds or enabled modules must be done in rspamd itself. |