Blacklist emails with DCC through a Perl script

DCC is a wonderful tool, but it needs to be fed constantly.
After going through the process of blacklisting a few emails that weren’t tag as spam, I found myself in a not so lazy position. We don’t like that … so we wrote a Perl script to kind of automate this process. (yes, we talk in plural since we are feeling quite majestic today)


The process is actually fairly simple, and this should be practically the biggest reason to automate this process.
DCC will create a text file for every email it checks (whether you like it or not), in /var/dcc/log. The bottom of those files contain variables and HEX values which are required to white- or blacklist messages in the DCC server.

Example of a text file generated by DCC (such the bottom actually):

In most cases, black- or whitelist entries will be created based on the fields ‘Body’, ‘Fuz1’ or ‘Fuz2’ (or all three will be added), but it is also possible to create criteria based on ‘IP’, ‘From’, …

Quick Overview of the process:

  1. Locate the correct text file in /var/dcc/log
  2. Grab the fields you want to white- or blacklist
  3. prefix these fields with either ‘many hex’ or ‘ok’
  4. Add those fields to the corresponding file in /var/dcc

In my case, I’ve created a file called /var/dcc/blacklist_spam which is included from /var/dcc/whiteclnt

The script goes as follows:

The criteria I use in order to search the emails is usually the Message-ID field, since this should be a unique identifier.

Comments are closed.