Retrieving Emails From Remote Servers With getmail (Debian Etch) - Page 2
4 Integrating SpamAssassin Into getmail
If you'd like getmail to invoke SpamAssassin, you can do it as follows:
First we must install SpamAssassin. As root, we run
apt-get install spamassassin spamc
Then we must configure SpamAssassin. This can be done in the file /etc/mail/spamassassin/local.cf. A valid file could look like this:
vi /etc/mail/spamassassin/local.cf
rewrite_header Subject *****SPAM***** required_score 5.0 use_bayes 1 bayes_auto_learn 1 bayes_ignore_header X-Bogosity bayes_ignore_header X-Spam-Flag bayes_ignore_header X-Spam-Status bayes_ignore_header X-getmail-filter-classifier |
(The comments in /etc/mail/spamassassin/local.cf will tell you more about the above settings.)
If you enable Bayes (use_bayes 1), it is important that you put the line
bayes_ignore_header X-getmail-filter-classifier
into /etc/mail/spamassassin/local.cf so that Bayes ignores headers added by getmail.
Finally we must enable the SpamAssassin daemon by setting ENABLED to 1 in /etc/default/spamassassin:
vi /etc/default/spamassassin
[...] ENABLED=1 [...] |
Then we start the SpamAssassin daemon:
/etc/init.d/spamassassin start
Now log in as falko again on the command line and open ~/.getmail/getmailrc and add the following [filter] section:
vi ~/.getmail/getmailrc
[...] [filter] type = Filter_external path = /usr/bin/spamc arguments = ("-s 250000", ) |
(If this is not your first [filter] section, you must rename the first [filter] section to [filter-1], the second one to [filter-2], and so on.)
That's it. SpamAssassin is now integrated into getmail.
5 Integrating ClamAV
ClamAV is a project that publishes new releases very often, and once a new release is published, old versions will print out warnings. Therefore we must make sure that we install the latest ClamAV release by adding the following line to /etc/apt/sources.list (as root):
vi /etc/apt/sources.list
[...] deb http://volatile.debian.org/debian-volatile etch/volatile main contrib non-free [...] |
Afterwards we update our packages database:
apt-get update
(- if you get GPG warnings, you can ignore them -)
and install ClamAV:
apt-get install clamav clamav-base clamav-daemon clamav-freshclam
Then log in as the user falko again and edit ~/.getmail/getmailrc. If you want getmail to delete virus emails, add the following filter:
vi ~/.getmail/getmailrc
[...] # Drop infected messages [filter] type = Filter_classifier path = /usr/bin/clamdscan arguments = ("--stdout", "--no-summary", "-") exitcodes_drop = (1, ) |
If you want getmail to deliver infected messages, add the following filter instead:
vi ~/.getmail/getmailrc
[...] # Keep infected messages [filter] type = Filter_classifier path = /usr/bin/clamddscan arguments = ("--stdout", "--no-summary", "-") exitcodes_keep = (0,1) |
Again, keep in mind what I said about multiple [filter] sections in the previous chapter:
If this is not your first [filter] section, you must rename the first [filter] section to [filter-1], the second one to [filter-2], and so on.
That's it for the ClamAV integration.