Retrieving Emails From Remote Servers With getmail (Debian Etch) - Page 2

Want to support HowtoForge? Become a subscriber!
Submitted by falko (Contact Author) (Forums) on Thu, 2007-06-14 15:07. ::

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/ A valid file could look like this:

vi /etc/mail/spamassassin/

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/ 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/ 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


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


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 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
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
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.

Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.