Spamdyke as Antispam Solution in Plesk with Qmail


First of all you need to make sure that you have the necessary packages to compile spamdyke:

apt-get install gcc make libc-dev
 
Then download the latest version:
 
At the moment that I'm writing this howto, the latest version is 4.0.10:
wget http://www.spamdyke.org/releases/spamdyke-4.0.10.tgz
tar -xvzf spamdyke-4.0.10.tgz
cd spamdyke-4.0.10/spamdyke
 
After unpacking it, you just have to configure and compile it:
./configure
make
 
If everything goes ok, you should now find the spamdyke executable in your folder which you now should copy to /usr/local/bin:
cp spamdyke /usr/local/bin/
 
Ok, so far so good, spamdyke installation is already done. Now we have proceed to integrate it into Plesk.
 
Using Plesk8 and Debian, the system usually uses xinetd. Let's create a backup of the original files first:
cp /etc/xinetd.d/smtp_psa /etc/xinetd.d/smtp_psa.orig

 

 

 

 

cp /etc/xinetd.d/smtps_psa /etc/xinetd.d/smtps_psa.orig

 
Then you edit the files smtp_psa and smtps_psa and add the following line directly in front of /var/qmail/bin/qmail-smtpd (please keep attention that you add it on the same line without causing a line break):
/usr/local/bin/spamdyke -f /etc/spamdyke.conf
 
Then restart xinetd:
/etc/init.d/xinetd restart
 
ATTENTION!
Depending on your plesk version your system may use either inetd or xined.
 
In case if inetd, you have to add
/usr/local/bin/spamdyke -f /etc/spamdyke.conf
in the file /etc/inetd.conf directly in front of /var/qmail/bin/qmail-smtpd.
You can restart inetd then using:
/etc/init.d/inetd restart
 
Next we need to create spamdyke's configuration file /etc/spamdyke.conf:
log-level=2
local-domains-file=/var/qmail/control/rcpthosts
max-recipients=20
idle-timeout-secs=60
graylist-dir=/var/qmail/spamdyke/greylist
graylist-min-secs=300
graylist-max-secs=1814400
sender-blacklist-file=/var/qmail/spamdyke/blacklist_senders
sender-whitelist-file=/var/qmail/spamdyke/whitelist_senders
recipient-blacklist-file=/var/qmail/spamdyke/blacklist_recipients
ip-in-rdns-keyword-file=/var/qmail/spamdyke/blacklist_keywords
ip-blacklist-file=/var/qmail/spamdyke/blacklist_ip
rdns-whitelist-file=/var/qmail/spamdyke/whitelist_rdns
ip-whitelist-file=/var/qmail/spamdyke/whitelist_ip
reject-empty-rdns
reject-unresolvable-rdns
greeting-delay-secs=5
check-dnsrbl=bl.spamcop.net
reject-missing-sender-mx
 
You may want to adapt the values to your needs, but the shown configuration above should be ok to start up.
A list of all available options can be found here:
 
Ok, now we need to create spamdyke's greylist folder and its black and whitelist files in qmail:
mkdir -p /var/qmail/spamdyke/greylist
touch /var/qmail/spamdyke/blacklist_ip
touch /var/qmail/spamdyke/blacklist_recipients
touch /var/qmail/spamdyke/whitelist_ip
touch /var/qmail/spamdyke/blacklist_keywords
touch /var/qmail/spamdyke/blacklist_senders
touch /var/qmail/spamdyke/whitelist_senders
touch /var/qmail/spamdyke/whitelist_rdns
chown -R qmaild:nofiles /var/qmail/spamdyke
 
By changing one of the files, you always need to restart xinetd/inetd and qmail!
 
If you already have existing e-mail accounts on your Plesk installation, you need to create their greylist folders:
cd /var/qmail/spamdyke/greylist/
for i in `ls -1 /var/qmail/mailnames`; do mkdir $i; done
chown -R qmaild:nofiles /var/qmail/spamdyke
 
For this to happen automatically upon creation of a new e-mail account, you should add the file /usr/local/psa/bin/create_greylist_folder.sh:
#!/bin/bash
# greylist folder
greylist_path="/var/qmail/spamdyke/greylist"
# add new folder
mkdir $greylist_path/$1
# create proper permissions
chown qmaild:nofiles $greylist_path/$1
exit
 
And adapt its permissions:
chown root:root /usr/local/psa/bin/create_greylist_folder.sh
chmod 755 /usr/local/psa/bin/create_greylist_folder.sh
 
Then you need to add the new script to the Plesk Event Manager which you find in the Server area.
spamdyke-plesk-qmail-integration-1
 
There you click on "Add Event Handler":
spamdyke-plesk-qmail-integration-2
 
And add the new event as follows:
spamdyke-plesk-qmail-integration-3
 
Event: Domain created
Priority: Normal
User: root
Command: /usr/local/psa/bin/create_greylist_folder.sh
 
That's it. Now you should send some testing e-mails and have a look at your logs: /var/log/mail.info, /var/log/mail.log