Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| email:mailscanner [2025/06/16 08:08] – created - external edit 127.0.0.1 | email:mailscanner [2026/04/13 14:52] (current) – [Web interface] willy | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== N) Mail Scanner | + | ====== N) Spam filtering |
| - | The DNS (Domain Name Service) plays a critical role in email delivery. You need to create | + | [[https:// |
| - | The basic record to setup is the MX record, which tells the email servers //which server(s)// handle email for your domain. | ||
| - | This page will make a general overview of all the needed records, more details are presented in each configuration section later on. | + | ===== Installation ===== |
| - | Please __note__ that you will need **more** that the records defined in this page for a domain to operate properly: this is only for email. | + | My VPS is pretty ancient and the CPU does not support sse4_2, instructions, |
| + | <file - rspamd> | ||
| + | mail-filter/ | ||
| + | </ | ||
| + | Now simply emerge it: | ||
| + | <code bash> | ||
| + | emerge -vp rspamd dev-db/ | ||
| + | </ | ||
| - | ===== Reverse DNS ===== | + | rspamd requires redis, but somehow it doesn' |
| - | A reverse DNS setup is how you translate an IP to a DNS name. This is the // | ||
| - | This is important to be properly set, and is usually defined aside from your actual DNS management panel of your provider. | + | ===== Configure rspamd ===== |
| - | If you cannot set it, some providers don't support it, it's ok. Better set it up, if possible. When set, it will help email deliverability. | + | Create **/ |
| + | <file - actions.conf> | ||
| + | # Basic action thresholds | ||
| + | reject = 15; # Reject obvious spam | ||
| + | add_header = 6; # Add spam headers | ||
| + | greylist = 4; # Temporary delay suspicious mail | ||
| + | </ | ||
| + | Configure redis **/ | ||
| + | <file redis.conf> | ||
| + | # Redis connection for statistics and caching | ||
| + | servers = " | ||
| + | </ | ||
| - | ===== MX record ===== | + | Setup a controller password for the web interface: |
| + | <code bash> | ||
| + | rspamadm pw | ||
| + | </ | ||
| - | An **MX** record (mandatory) tells who manages emails for your domain. You can have more than one, to build a chain of backup servers, but that is outside the scope of this guide. I assume your MX record points to **mail.mydomain.com**. | + | Create |
| + | <file - worker-controller.inc> | ||
| + | # Replace with your generated password | ||
| + | password = " | ||
| + | </ | ||
| - | Please note that this implies as well the existence of an **A** record for // | ||
| - | Example: | + | ===== Configure redis ===== |
| - | < | + | |
| - | mail.mydomain.com. | + | |
| - | webmail.mydomain.com. mail.mydomain.com. | + | |
| - | @ 10 mail.mydomain.com. 3600 MX | + | |
| - | </ | + | |
| + | Setup redis at least in a basic and secure way **/ | ||
| + | <file - redis.conf> | ||
| + | # Bind only to localhost for security | ||
| + | bind 127.0.0.1 ::1 | ||
| + | # Set memory limit | ||
| + | maxmemory 500mb | ||
| + | maxmemory-policy volatile-ttl | ||
| + | </ | ||
| - | ===== SPF record ===== | ||
| - | For SPF to work, you need to setup a proper TXT record like the following: | + | ===== Configure postfix link ===== |
| - | < | + | |
| - | @ v=spf1 mx a -all 3600 TXT | + | |
| - | </ | + | |
| - | + | ||
| - | + | ||
| - | ===== DKIM record | + | |
| - | The DKIM record contains the public part of your domain DKIM keys: | + | Add milter integration to your Postfix configuration in **/ |
| < | < | ||
| - | mydomain.com._domainkey. "v=DKIM1; k=rsa; p=<< mykey >>" | + | # Enable Rspamd milter |
| + | smtpd_milters | ||
| + | milter_default_action | ||
| + | milter_protocol | ||
| </ | </ | ||
| - | In the above example | + | Configure Rspamd proxy worker in **/etc/rspamd/local.d/worker-proxy.inc**: |
| + | <file - worker-proxy.inc> | ||
| + | # Enable milter mode for Postfix integration | ||
| + | milter = yes; | ||
| + | timeout = 120s; | ||
| + | upstream " | ||
| + | default = yes; | ||
| + | self_scan = yes; # Scan messages directly | ||
| + | } | ||
| + | </ | ||
| - | ===== DMARC record | + | ===== Startup |
| - | The DMARC record is used to publish your domain DMARC strategy | + | Ensure all the services are running and setup to start on boot: |
| - | < | + | < |
| - | _dmarc.mydomain.com. " | + | for i in rspamd redis postfix |
| - | _smtp_tls.mydomain.com. """ | + | do |
| + | | ||
| + | / | ||
| + | done | ||
| </ | </ | ||
| - | ===== Discoverability records | + | ===== Web interface |
| - | The following set of SRV records facilitate | + | By default rspamd web interface is exposed on **http:// |
| < | < | ||
| - | _imaps._tcp.mail.mydomain.com. 0 1 993 mail.mydomain.com. 3600 SRV | + | location /rspamd/ { |
| - | _submissions._tcp.mail.mydomain.com. 0 1 465 mail.mydomain.com. 3600 SRV | + | proxy_pass http://127.0.0.1:11334/; |
| - | _imap._tcp.mail.mydomain.com. 0 1 143 mail.mydomain.com. 3600 SRV | + | proxy_redirect |
| - | _submission._tcp.mail.mydomain.com. 0 1 587 mail.mydomain.com. 3600 SRV | + | |
| + | proxy_set_header | ||
| + | proxy_set_header | ||
| + | proxy_set_header | ||
| + | proxy_set_header | ||
| + | } | ||
| </ | </ | ||
| + | |||