DSPAM With Embedded ClamAV Integrated Into Postfix With Virtual Users And Domains - Page 2

Want to support HowtoForge? Become a subscriber!
Submitted by o.meyer (Contact Author) (Forums) on Tue, 2007-08-14 17:08. ::

5 Configure Postfix

Now we integrate DSPAM into Postfix:

vi /etc/postfix/master.cf


smtp inet	n	-	-	-	-	smtpd


smtp inet	n	-	-	-	-	smtpd
     -o content_filter=lmtp:unix:/var/run/dspam.sock

After DSPAM has checked the mails, it will send it back to postfix. So we need to
configure Postfix for reinjection, without sending a checked mail again to DSPAM.
Add the following content:	inet	n	-	-	-	-	smtpd
		-o content_filter=
		-o receive_override_options=no_unknown_recipient_checks,no_header_body_checks
		-o smtpd_helo_restrictions=
		-o smtpd_client_restrictions=
		-o smtpd_sender_restrictions=
		-o smtpd_recipient_restrictions=permit_mynetworks,reject
		-o mynetworks=
		-o smtpd_authorized_xforward_hosts=

Restart Postfix:

/etc/init.d/postfix restart

Now we test if Postfix is working correctly:

telnet localhost 25

Should look like this:

Connected to localhost.localdomain.
Escape character is '^]'.
220 debian.example.com ESMTP Postfix (Debian/GNU)

ehlo localhost

Should look like this:

250-SIZE 10240000
250 DSN

Quit telnet:



6 Create First Mailaccount

If you are asked for the mysql-root-password, insert the one you chose in the howto before at step 4.

mysql -u root -p
USE mail;

INSERT INTO `domains` (`domain`) VALUES ('example.com');
INSERT INTO `users` (`email`, `password`, `quota`) VALUES ('test@example.com', ENCRYPT('userpassword'), 10485760);

Now the mail-account should be ready to use.
Postfix will automatically create the Maildirs when the first mail arrives to this account. So before you can get mails, you have to send one first to this account.

Recognized Spam will be marked with "SPAM" in the subject. To be sure that DSPAM has processed your mails, all mails will have an entry at the bottom like "!DSPAM:46b904f4169391516232331!".


7 Train DSPAM

It would be useful to train DSPAM with spam and no-spam for better spam-detection.
Install bzip2:

apt-get install bzip2

Get train-mails:

cd /tmp
wget http://spamassassin.apache.org/publiccorpus/20050311_spam_2.tar.bz2
wget http://spamassassin.apache.org/publiccorpus/20030228_easy_ham_2.tar.bz2

tar xvfj 20050311_spam_2.tar.bz2
tar xvfj 20030228_easy_ham_2.tar.bz2

Train DSPAM:

dspam_train test spam_2/ easy_ham_2/

DSPAM will now process the files (this will take a while) and fill the database with the resulting tokens.


8 Install And Configure ClamAV

apt-get install clamav-daemon

Change the configuration:

vi /etc/clamav/clamd.conf

Comment out "LocalSocket /var/run/clamav/clamd.ctl" (with a #) and add the new line:

TCPSocket	3310

Restart ClamAV:

/etc/init.d/clamav-daemon restart


9 Integrate ClamAV Into DSPAM

vi /etc/dspam/dspam.conf

Change the existing lines so that they look like this:

ClamAVPort     3310
ClamAVResponse reject

Restart DSPAM:

/etc/init.d/dspam restart


10 Links

Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by kirma (registered user) on Fri, 2007-08-24 10:06.
Thanks for your howto!
During the setup I have discovered  an error on accessing the smtp server by

telnet localhost 25

This error is caused by

nano /etc/postfix/master.cf

[...] 10026 inet n - - - - smtpd

Change this line into (delete the space between ": 10026"):

[...] inet n - - - - smtpd

Best regards,