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

5 Configure Postfix

Now we integrate DSPAM into Postfix:

vi /etc/postfix/master.cf

Change:

smtp inet	n	-	-	-	-	smtpd

To:

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:

127.0.0.1:10026	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=127.0.0.0/8
		-o smtpd_authorized_xforward_hosts=127.0.0.0/8

Restart Postfix:

/etc/init.d/postfix restart

Now we test if Postfix is working correctly:

telnet localhost 25

Should look like this:

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

Should look like this:

250-debian.example.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN

Quit telnet:

quit

 

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 ('[email protected]', 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
ClamAVHost     127.0.0.1
ClamAVResponse reject

Restart DSPAM:

/etc/init.d/dspam restart

 

Share this page:

1 Comment(s)