Full Mail Server Solution w/ Virtual Domains & Users (Debian Etch, Postfix, Mysql, Dovecot, DSpam, ClamAV, Postgrey, RBL) - Page 8

F. Training DSPAM

DSPAM can learn what spam is by reading your email, and over time, it will get better at figuring out spam vs. ham by your sending it "spam+user@example.com" and "nospam+user@example.com" messages. You can get a head start though, but giving it some initial training. Let's go ahead and set that up.

You're going to need bzip2

# apt-get install bzip2

Then you're going to need to download the training files for DSPAM.

# 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

Go ahead and decompress them:

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

...and then finally, 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. When it is finished, it should be much more accurate.

G. Viruses!

But hold the phone! What if an email from a VALID source has a virus in it? Well, DSPAM has a nifty tag built into it for ClamAV. So let's get that installed... Debian, again, is awesome:

# apt-get install clamav-daemon

Do a quicky edit of the clamav configuration file to uncomment the TCPSocket line:

/etc/clamav/clamd.conf

[...]
TCPSocket 3310
[...]

... and restart clamav:

# invoke-rc.d clamav-daemon restart

The edit /etc/dspam/dspam.conf

[...]
ClamAVPort 3310
ClamAVHost 127.0.0.1
ClamAVResponse reject
[...]

Restart dspam:

invoke-rc.d dspam restart

And they all lived happily ever after... DSPAM will now check for SPAM, and then check for viruses. SPAM will be put in the aptly-named "SPAM" folder, and the subject will be modified to start with "[SPAM]." Emails with viruses in them will get flat-out rejected by the server.

Share this page:

Sub pages

5 Comment(s)

Add comment

Comments

From: at: 2008-03-27 06:06:28

Hi Vector,

I would just like to know how the mail gets transferred from the MX's to the delivery server (postman). I'm trying to understand how this full mail server setup works because I would like to implement something similar to this but using centos and ldap users.  

From: Stefan at: 2008-11-01 18:07:49

There is no explanation on how the mail is actually transfered from the MX server to the Mail Delivery Server. Using the steps in the guide will make the MX server try to deliver the mail directory into the NFS shared vmail folder, which isn't the desired behaviour.

From: Matt at: 2009-06-15 13:16:16

"NOTE: This is a temporary setup, just because we hadn't finished the DSPAM virtual user install prior to writing this guide. Ideally, you'd want DSPAM looking at the same virtual user table as Postfix in order to get all the token information stored correctly. I'll update the guide as soon as we've completed that change-over."

 Has this been updated anywhere? can anyone shed some light on what changes should be made?

 

From: mbsouth at: 2009-09-10 10:02:01

Would be nice to have an updated howto (based an this one) with Debian Lenny, Postfix 2.5(6), Dovecot 1.1(2) on three nodes (2xSMTP Postfix, 1x Dovecot IMAP/POP3)

 

From: at: 2007-11-15 20:55:15

Heads up when using the configuration examples for the mailbox path. Since maildir:/vmail/%d/%u is used in dovecot.conf, you should do the same in dovecot-sql.conf.

Such as:

# Get the mailbox
user_query = SELECT '/vmail/%d/%u' AS home, 'maildir:/vmail/%d/%u' AS mail, 150 AS uid, 8 AS gid, CONCAT('dirsize:storage=', quota) AS quota FROM mailbox WHERE username = '%u' AND active = '1'
# Get the password
password_query = SELECT username AS user, password, '/vmail/%d/%u' AS userdb_home, 'maildir:/vmail/%d/%u' AS userdb_mail, 150 AS userdb_uid, 8 AS userdb_gid FROM mailbox WHERE username = '%u' AND active = '1'

Otherwise mail is delivered to /vmail/domain/user@domain and then IMAP checks /vmail/domain/user

Or change dovecot.conf to maildir:/vmail/%d/%n if you prefer the latter.