Spam flagging using DNSBL - dnsspam.conf

Hello,

I would like to use a custom DNSBL ‘dnsspam.conf’ next to / after the default ‘dnsbl.conf’ to flag incoming email as spam instead of blocking them immediately. This way I would be able to use a dns blocklist like ix.dnsbl.manitu.net without risking false positives.
Is this easy to implement?

I’ve added this block to my exim4.conf.template, directly after: ${readfile {/etc/exim4/dnsbl.conf}{:}}:

warn
    dnslists     = ${readfile {/etc/exim4/dnsspam.conf}{:}}
    add_header   = X-Spam-Flag: YES
    add_header   = X-Spam-Reason: DNSBL - $dnslist_domain
    log_message  = Message sent to spam due to dnsspam.conf
    set acl_m_spam = yes

I do see the log_message correctly show up in the exim mainlog but the email is not put into the spam folder.

Any help is much appreceated!

1 Like

Okey I found a solution:

  1. First create the dnsspam.conf in /etc/exim4/

  2. Add the following block in /etc/exim4/exim4.conf.template just below this line:
    dnslists = ${readfile {/etc/exim4/dnsbl.conf}{:}}

warn
    dnslists     = ${readfile {/etc/exim4/dnsspam.conf}{:}}
    add_header   = X-Spam-Flag: YES
    add_header   = X-Spam-Reason: DNSBL - $dnslist_domain
    log_message  = Message sent to spam due to DNS list: $dnslist_domain
    set acl_m_spam = yes
  1. Replace the default localuser_spam block with:
localuser_spam:
  driver = accept
  transport = local_spam_delivery
  condition = ${if or { \
      {eq{$acl_m_spam}{yes}} \
      {eq {${if match{$h_X-Spam-Status:}{\N^Yes\N}{yes}{no}}} \
           {${lookup{$local_part}lsearch{/etc/exim4/domains/${lookup{$domain}dsearch{/etc/exim4/domains/}}/passwd}{yes}{no_such_user}}} \
      } \
    }{yes}{no}}

This will first check against the dnsspam.conf and than continue with SpamAssassin.

  1. Restart exim4

Note: If anyone has improvements. They are still welcome :slight_smile:

7 Likes