This one is fairly simple, I noticed how many of these approaches involve fetchmail, getmail, sendmail, qmail, procmail, thismail and thatmail.... but this one only involves one perl script (DisSpam), plus a perl module for antispam (SpamAssassin), plus a package for antivirus (ClamAV).
To put it simply:
DisSpam connects to your POP3 mailserver regularly, deletes all the mails it thinks are spam and/or viruses, and disconncts.
Based on a page I wrote on my website, here
Installing perl modules
Some of what we need is in portage, some isn't. It's simple to obtain other perl modules through CPAN.
As root,
Firstly:
Code: Select all
emerge Net-DNS Mail-SpamAssassin MIME-tools clamavCode: Select all
perl -MCPAN -e shell
# answer the questions if you have never been into CPAN before (defaults are usually safe)
install Inline::MakeMaker
force install Mail::ClamAV
exit
Updating virus definitions
To update to the latest virus definitions, as root, execute:
Code: Select all
freshclamDownloading and patching DisSpam
DisSpam 0.12 vanilla supports spam filtering. I recently wrote a patch to add anti-virus mail filtering, which is currently being reviewed by the author. So for now, we will have to patch the DisSpam source manually.
It is recommended that you use a non-root user to set up and configure disspam. From a shell:
Code: Select all
wget http://freshmeat.net/redir/disspam/22053/url_tgz/disspam-0.12.tar.gz
tar xzvf disspam-0.12.tar.gz
cd disspam
wget http://www.reactivated.net/patches/disspam-0.12/disspam-virus-checking.patch
patch -p1 < disspam-virus-checking.patchDisSpam configuration
Copy the file sample.conf to disspam.conf and open disspam.conf in your favourite text editor, i.e.:
Code: Select all
cp sample.conf disspam.conf
nano disspam.confCode: Select all
# spamassassin=yes
# clamav=yes
# avtemporary=/tmp/clamav.temp
# mimestore=/tmp/mimestoreThe [RBL] section may be left alone, as we are using SpamAssassin for spam filtering.
Now you must configure a mailbox that DisSpam will filter. You will see a section in the config file marked "Your custom mailbox section(s) start here". Below that, there are some sample values. You need to change the email, host, username, and password keys to your personal values.
Personally, I like to set the backupfile option to store any mails that are filtered and deleted. I have been using SpamAssassin for over a year and it has only turned up one "false positive" that I know about. This option will store all the "spam" mails, and that may be helpful, if you ever lose an important mail!
I also like to enable the sendbounceback option. This option will "bounce" any mails that are filtered out by DisSpam. This informs the senders of any mails that become "false positives" that I have *not* read their mail, and also acts as a spam-the-spammer measure!
If you are interested in the configuration, you should read configuration.txt included in the distribution.
Test run
When you are happy with the configuration, run DisSpam to check that it works as expected:
Code: Select all
./disspam.pl disspam.confAutomation with cron
Assuming all is working well, you now want to schedule DisSpam to run regularly, and it may also be useful to keep ClamAV up to date automatically.
We will use cron here to automate these tasks. As the user that you wish to filter the spam with, run:
Code: Select all
crontab -eCode: Select all
0 * * * * /home/spam/disspam.pl /home/spam/disspam.conf > /home/spam/spamlog &- 0 * * * * - This is cron notation which means "run every hour, on the hour". Tutorials such as this one do a good job at explaining this notation.
- /home/spam/disspam.pl - This is the absolute location of my disspam.pl file from the DisSpam distribution.
- /home/spam/disspam.conf - This is the absolute location of my disspam.conf file which we created in step 4.
- /home/spam/spamlog - This is a file where I log the output of DisSpam's most recent run. If you don't want to log this, then use /dev/null here.
Code: Select all
0 0 * * * freshclam > /dev/nulland thats it
let me know if you have any problems/questions, and i'll do my best to help.
dsd





