How to Reject Email

NethServer Version: NS8
Module: Mail

Hi everyone i want to reject email from certain address and specific object how can i achieve that on NS8 WebUI?
Thanks in advice :slight_smile:

Hi,

The GUI does not support this functionality with NS8.

I’ve spent many hours reading Nethserver documentation to learn how to customize RSPAMD to block certains TLDs and email addresses, but I haven’t had any success.

Here’s what I’ve learned to date. I would appreciate if someone could either validate or provide corrections to my findings.

  1. All configuration & data for each module is located in /home.
  2. The command “sudo runagent -m mail1 podman exec -ti rspamd ash” will open a shell in the RSPAMD container.
  3. Any override settings files should be created in /etc/rspamd/override.d.
  4. Any changes to files in /etc/rspamd/local.d are not persistent and will be lost.
  5. Any files created in /etc/rspamd/local.d or any of it’s sub-directories are not persistent and will be lost.

Based on my research, I’ve identified a significant gap in the documentation for NS8 regarding the API client, runagent and podman usage for manual customizations. While there are scattered bits of information available, none provide a comprehensive and clear guide that is truly helpful.

Kind Regards,

Dominic

Hi Denis,

I have learned how to block email addresses and top-level domains (TLDs).

  1. Launch a shell in the rspamd container.
sudo runagent -m mail1 podman exec -ti rspamd sh
  1. Copy /etc/rspamd/local.d/multimap.conf to /etc/rspamd/override.d/multimap.conf
cp /etc/rspamd/local.d/multimap.conf /etc/rspamd/override.d/multimap.conf
  1. Open multimap.conf.
vi /etc/rspamd/override.d/multimap.conf
  1. Paste the following in multimap.conf.
BLOCK_SENDER_FROM_TLD {
    type = "from";
    filter = 'top';
    symbol = "BLOCK_SENDER_FROM_TLD";
    prefilter = true;
    map = ["${DBDIR}/local_bl_from_tld.map.inc"];
    regexp = true;
    description = "TLD from Blacklist";
    action = "greylist";
}

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";
}
  1. Create the file local_bl_from_tld.map.inc in /var/lib/rspamd.
vi /var/lib/rspam/local_bl_from_tld.map.inc
  1. Paste the folliowing in local_bl_from_tld.map.inc.
[.]best$
  1. Create the file local_bl_from.map.inc.
vi /var/lib/rspamd/local_bl_from.map.inc
  1. Paste the email address(es) in local_bl_from.map.inc.
email@domain.tld

References:
NethServer / ns8-mail
RSPAMD Multimap Module

3 Likes

Hi Dominic, you did the right thing :+1:

Are you sure this step is needed? It looks like override.d contents are added with higher priority:

  .include(try=true,priority=5) "${DBDIR}/dynamic/multimap.conf"                               
  .include(try=true,priority=1,duplicate=merge) "$LOCAL_CONFDIR/local.d/multimap.conf"         
  .include(try=true,priority=10) "$LOCAL_CONFDIR/override.d/multimap.conf"      

Files under that directory once they’re created (for example with “touch”. as an empty file) with proper ownership (chown -c rspamd:rspamd) could be managed directly from Rspamd UI. E.g.

Note also that ${DBDIR}/dynamic/multimap.conf is already included, if it exists. You could try to set up the customization with it.


@Denis_Pollini, Dominic’s approach looks promising and is good in general, but configuring Sieve filters might be a valid alternative to Rspamd customization especially for small installations.

2 Likes

Hi David,

Thank you for your invalueable feedback. I truly appreciate it. :grinning:

Your right, this step isn’t necessary. I was unaware of the path ${DBDIR}/dynamic that did not exist. I’ve since created ${DBDIR}/dynamic, set the permissions, and moved the multimap.conf file, retaining only the customizations. It works!

I can confirm that the custom blacklist files created are accessible in the UI and can be managed directly from there.

Thanks,

Dominic

Hi @davidep @domins10 thx for answering.
So @domins10 can you provide with the information you get from @davidep to write step-by-step process to achieve that?So it can be useful to others.
Thanks

Hi Denis,

Absolutely, it would be my pleasure!

Where would be the best place to put the procedure–in the wiki?

1 Like

I’d suggest to write a post in the Howto category here, or in the community wiki.