Getmail

From Dracula's Wiki

getmail with spamassassin and virusscan (avira) howto

I recently got quite fed up of fetchmail. The problem is that there are mails on an account from invalid sender domains (like foo.bar for example) since my Postfix rejects such mail because it can only be spam fetchmail didn't manage to delete them. So it looped leaving the junk mails on the pop account and flooding my logfiles.
The solution was getmail. Since I use postfix + amavis + cyrus there was no example config that fits my needs so I did some experiments but finally a mail from Elimar Riesebieter on the Mailinglist solved my problem. UPDATE: This didn't quite solve my problem as it turned out later, about 2 years later  :)

Here is what I did on my debian system, I created a getmail directory in /etc/

mkdir /etc/getmail/
chown nobody /etc/getmail/

and a direcotry for logs

mkdir /var/log/getmail/
chown nobody /var/log/getmail/

Create a file for each user named username.conf based on this template

[options]
message_log = /var/log/getmail/getmaillog
delete = 1

[retriever]
type = SimplePOP3Retriever
server = pop.bar.com
username = user1
password = pass1

[destination]
type = MDA_external
path = /usr/sbin/sendmail
arguments = ("-i", "-bm", "user@test.com")
unixfrom = true

[filter-1]
type = Filter_external
path = /usr/bin/spamc
arguments = ("-s 250000", )

# Drop infected messages
[filter-2]
type = Filter_classifier
path = /usr/bin/antivir
arguments = ("--allfiles", "-noboot", "-nombr", "-rs", "-s", "-z", "-q")
exitcodes_drop = (1, )

I think server, username and password is quite obvious. Don't forget to change the email address of the recipient in the arguments line! Since I use cyrus with virtual hosts the account name = emailaddress. Filter-1 does the spam check with spamassassin, and filter-2 does the virus scan with antivir (from avira, former h+b EDV). I didn't use clamav since I think clamav sucks big time! For example the great issue with 99% CPU Usage when clamav is started. But if clamav runs fine for you then you can use clamav instead like this:

# Drop infected messages
[filter]
type = Filter_classifier
path = /usr/bin/clamdscan
arguments = ("--stdout", "--no-summary", "-")
exitcodes_drop = (1, )

Read more about this on howtoforge
Now, to get getmail run with all conf files I made a short script called getmail-all.sh

#!/bin/bash
GM="/usr/bin/getmail -q"

for ii in /etc/getmail/*.conf
do
        $GM -g/var/log/getmail -r$ii
done

ok, now only the cronjob and we are done, in /etc/crontab I added:

*/10 * * * * nobody /etc/getmail/getmail-all.sh

getmail with avira antivir (hb edv)

this has been removed. Was completely wrong what I was doing.