NS8: How to Block Top-Level Domains (TLD) and Email Addresses

  1. Access the leader node through SSH.

  2. Launch a shell in the rspamd container.
    sudo runagent -m mail1 podman exec -ti rspamd sh

  3. Create the directory “dynamic” in /var/lib/rspamd, if it does not exist.
    mkdir /var/lib/rspamd/dynamic

  4. Create the file multimap.conf in /var/lib/rspamd/dynamic.
    vi /var/lib/rspamd/dynamic/multimap.conf

  5. Insert the following content into the file multimap.conf. Save & Exit.

    BLOCK_SENDER_FROM_TLD {
        type = "from";
        filter = 'email:domain:tld';
        symbol = "BLOCK_SENDER_FROM_TLD";
        prefilter = true;
        map = ["${DBDIR}/local_bl_from_tld.map.inc"];
        regexp = true;
        description = "TLD from Blacklist";
        action = "reject";
        message = "Sender Domain REJECTED";
    }
    
    BLOCK_SENDER_FROM {
        type = "header";
        header = "from";
        filter = 'email';
        symbol = "BLOCK_SENDER_FROM";
        map = ["${DBDIR}/local_bl_from.map.inc"];
        description = "Email Address from Blacklist";
        action = "reject";
        message = "Sender Email Address REJECTED";
    }
    
  6. Set the owner on the directory /var/lib/rspamd/dynamic to ‘rspamd’.
    chown -R rspamd: /var/lib/rspamd/dynamic

  7. Set the permissions on the directory /var/lib/rspamd/dynamic.
    chmod -c 750 /var/lib/rspamd/dynamic

  8. Create the file local_bl_from_tld.map.inc /var/lib/rspamd.
    vi local_bl_from_tld.map.inc

  9. Add the top-level domain(s) to blacklist in the file. Save & Exit.
    [.]best

  10. Create the file local_bl_from.map.inc in /var/lib/rspamd.
    vi local_bl_from.map.inc

  11. Add the email address(es) to blacklist in the file. Save & Exit.
    info@publiclibrary.best

  12. Set the owner on the files to ‘rspamd’.
    chown rspamd: /var/lib/rspamd/local_bl_from_tld.map.inc
    chown rspamd: /var/lib/rspamd/local_bl_from.map.inc

  13. Set the permissions on the files.
    chmod -c 644 /var/lib/rspamd/local_bl_from_tld.map.inc
    chmod -c 644 /var/lib/rspamd/local_bl_from.map.inc

  14. Check the config of rspamd.
    rspamadm configtest
     If no errors, the result will be: syntax OK

  15. Reload the rspamd config.
    reload-config

  16. Exit the container shell.
    exit

  17. Exit the SSH session.
    exit

5 Likes

Hi Dominic,

Many thanks for your howto.

This addition is maybe handy

Herewith you can block spam by subject
Hopely all these setting willbe made standard in NS8 in the future and some options available in the ui

1 Like