Getmail
From Dracula's Wiki
getmail 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.
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 = ("-bm", "user@test.com")
unixfrom = true
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. 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)
Ok this one is obsolet for me because now everything runs trough postfix and so it also runs trough amavis and I don't need an extra filter for getmail.
But since I already have it, why not share it, maybe someone will find it useful.
This is based on the f-prot wrapper linked in the getmail Docu.
As you can see there still are some f-prot comments in there.
#!/bin/bash
#
# @(#)f-prot-wrapper.sh 1.1 04/13/04
#
# Copyright (c) 2004
# Ali Onur Cinar &060;cinar(a)zdo.com&062;
#
# License:
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for non-commercial purposes and without fee is hereby
# granted, provided that the above copyright notice appear in all copies
# and that both the copyright notice and this permission notice and
# warranty disclaimer appear in supporting documentation, and that the name
# of Ali Onur Cinar not be used in advertising or publicity pertaining to
# distribution of the software without specific, written prior permission.
#
# F-Prot Anti-Virus is the registered trademark of FRISK Software International.
#
formail=/usr/bin/formail # path to formail
fprot=/usr/bin/antivir # path to f-prot
tmp=/tmp # temporary dir.
pid=$$ # get pid
mailFile=${tmp}/fpw-${pid}-mail # temp mail file
fprotOut=${tmp}/fpw-${pid}-out # temp fprot file
addField () # adds the given
{ # header to mail
cat $mailFile | $formail -f -A "$1" > ${mailFile}.1\
&& mv ${mailFile}.1 $mailFile
}
cat > $mailFile # save body
$fprot --allfiles -noboot -nombr -rs -s -z $mailFile > $fprotOut # execure f-prot
case "$?" in # based status
0 ) addField "X-Virus: No" # no virus detected
;;
* ) addField "X-Virus: Yes" # virus detected
infection=(`grep Infection: $fprotOut`) # add information
addField "X-Virus-Infection: ${infection[@]:2}" # about the virus
;;
esac
programVersion=(`grep 'Linux Version:' $fprotOut`) # get program version
engineVersion=(`grep 'VDF version:' $fprotOut`) # get engine version
addField "X-Virus-AV: Avira AntiVir program\
${programVersion[@]:2} / engine\
${engineVersion[@]:2}"
addField "X-Virus-FW: antivir-wrapper.sh\
1.0 (www.zdo.com/articles/f-prot-wrapper.shtml)"
cat $mailFile # show the mail file
rm $mailFile # clean temporary
rm $fprotOut # files

