Advertisment

Dspam your Mail

author-image
PCQ Bureau
New Update

In the past issues of PCQuest, we have been carrying numerous articles on setting up and using anti-spam tools-both commercial and open source. We have covered open-source packages like Amavis and Spamassassin extensively (refer Mail Server, March 2005, PCQuest). But the Amavis and Spamassassin combo does not provide an easy interface to users to control their spam/ham list. That is, they provide no easy way to a layman to mark his mail as spam or ham on the mail server. 

Advertisment
Direct

Hit!
Applies to:

Linux System Administrator
USP: Easy mechanism for user-specific spam control
Primary Link:

http://dspam.nuclearelephant.com 
Google keywords: 'alternative for

spamassassin'

That's where there are packages like Maia Mailguard (refer Maia Mailguard, April 2005, PCQuest) which provides an easy to use Web-based front end for each user to log in and maintain their spam/ham mail. But Maia Mailguard does not come with a default installation of Amavis and have to be set up separately. Come to Dspam, a yet another open-source anti-spam package but with a difference. With Dspam, a user, say, Shekhar can declare a mail as spam simply by forwarding the mail to spam-shekhar@

What's more, it also provides a Web-based interface to see all the quarantined mail, analyze the performance of the anti-spam package and even view the history of the spam/ham mail. 

Advertisment

Let's go through setting up Dspam on PCQLinux 2005 (the Linux distribution given out with the March 2005 issue of PCQuest). We will setup Dspam with Postfix mail server on PCQLinux 2005. We assume that before proceeding further, you have set up Postfix and Fetchmail (required to retrieve mail from an Internet mail server) as explained in the article Mail Server in the March 2005 issue of PCQuest. Skip the section 'Set up anti-spam and anti-virus', of the article, for setting up Amavis for Postfix.

Set up Dspam



Download the latest stable version (version 3.4.9) of Dspam from http://dspam.nuclearelephant.com. Extract the archive and change to the directory named dspam-3.4.9. Issue the following:

./configure; make; make install

Advertisment

It will install Dspam in /usr/local. Open the file named dspam.conf, found in /usr/local/etc. Add the following line:

UntrustedDeliveryAgent "/usr/bin/procmail -d %u"

Next, scroll down to the section which says 'Trusted Users'. The entries under this section must look as follows:

Advertisment

Trust root



Trust mail


Trust mailnull


Trust smmsp


Trust daemon


Trust apache



Uncomment or remove the remaining entries in this section. Save the file.

Set up Postfix for Dspam 



As said above, each user can forward mail to Dspam to record it as a spam. For the e-mail addresses like spam-@ to work, e-mail aliases for each mail user on the Linux machine must be created. Fortunately, Dspam comes with an easy to use script to create these aliases. Change to /usr/local/bin and issue:

Advertisment

dspam_genaliases --minuid 500 > /etc/postfix/dspam.aliases

Create an alias database for Postfix by issuing this command:

postalias /etc/postfix/dspam.aliases

Advertisment

Next, open the file named main.cf found in the directory /etc/postfix. Find the line which says:

alias_maps = hash:/etc/aliases

and modify it to:

Advertisment

alias_maps = hash:/etc/aliases,

hash:/etc/postfix/dspam.aliases

Find the section named 'DELIVERY TO MAILBOX'. Within this section, add the following line:

mailbox_command = /usr/local/bin/dspam --deliver=innocent --user $USER -- -d %u

Save main.cf and restart Postfix as:

service postfix restart 

Set up the Web interface



To set up the Web-based interface for Dspam, copy the directory named cgi-found in dspam-3.4.9 - to /var/www/cgi-bin. Open the file named httpd.conf, found in /etc/httpd directory in a text editor. Find the lines which say:





AllowOverride None


Options None


Order allow,deny


Allow from all






Substitute “AllowOverride None” with “AllowOverride AuthConfig”. Create a file named .htaccess in /var/www/cgi-bin/cgi with the following content:

AuthType Basic



AuthName "Dspam"


AuthUserFile /etc/httpd/conf/htpasswd/dspam


Require valid-user

This is required to authenticate each mail user accessing the Dspam's Web-based interface, and it also lets Dspam know the user for whom it should display the statistics. Now we need to create a htpasswd file with the usernames of all mail users on the system. 

All done. Now when you retrieve mail through fetchmail, they will be handled over to Postfix and in turn to Dspam which will scan the mail for spam. In case, you get a mail which is spam you can forward it as explained above. Mail users can can view the Web-based statistics for the mail by loading up the following URL in a web browser:

http:///cgibin

/cgi/ dspam.cgi.

When the authentication box pops up, the user should enter his username on the Linux machine and the password you have set for him while setting up the htpasswd. 

Shekhar Govindarajan, IT4Enterprise

Advertisment