fetchmail - procmail issues

Hi everybody,
I hope I can find some help here.
Recently I tried to change the configuration of an email-server.
Before I used postfix, fetchmail & IMAP server. Now I want to use procmail for SPAM/Virus Detection. The reason is that the Mail-Server was only used for Intranet-Mail, where each user used their own MUA for mail retrieval. Now, with new security messures, the mail-retrieval shall be centralised on the server.

fetchmail → IMAP works well but
fetchmail → procmail → IMAP fails.

I am using:

  • OpenSuSE 11.0
  • fetchmail-6.3.8-134.1
  • procmail-3.22-203.1
  • postfix-2.5.1-28.5
  • cyrus-imapd-2.3.11-31.1

After lots of reading & some trial & error I came up with the following:

/etc/fetchmailrc:
poll “pop.gmx.net” protocol pop3: user “user1@gmx.de” there with password “" is “user1” here ;
poll “pop.gmx.net” protocol pop3 : user “user2@gmx.de” there with password "
” wants mda “/usr/bin/procmail” is user2 here;

the 1st user is for testing purpose, and the mail retrieval works well.

/etc/procmailrc:

VERBOSE=yes
SHELL="/bin/bash"
DELIVERMAIL="/usr/lib/cyrus/bin/deliver"
LOGFILE="/var/log/procmail.log"
IMAP="$DELIVERMAIL -a $USER -m $USER"
LOG="My PATH is currently $PATH
My SHELL is currently $SHELL
My USER is currently $USER
My LOGNAME is currently $LOGNAME
"
###########################################################

Deliver it to the user inbox

###########################################################

:0 w
| $IMAP

The ‘LOG’ entry was for testing purpose only. No filtering rules yet, just wanted to get the mail delivered. But the log comes up with:

/var/log/procmail.log:

procmail: Assigning "IMAP=/usr/lib/cyrus/bin/deliver -a -m "
procmail: Assigning "LOG=My PATH is currently /bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
My SHELL is currently /bin/bash
My USER is currently
My LOGNAME is currently root
"
My PATH is currently /bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
My SHELL is currently /bin/bash
My USER is currently
My LOGNAME is currently root
procmail: Executing “/usr/lib/cyrus/bin/deliver,-a,-m”
421-4.3.0 usage: deliver -C <alt_config> ] -m mailbox] -a auth] -r return_path] -l] -D]
421 4.3.0 v2.3.11
procmail: Program failure (75) of “/usr/lib/cyrus/bin/deliver”
procmail: Assigning “LASTFOLDER=/usr/lib/cyrus/bin/deliver -a -m”
procmail: Assigning “PATH=/root/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin/X11”
Subject: Test 30
Folder: /var/spool/mail/root 1155

My conclusion: $USER is not set, this is why deliver fails.
My questions:

  • Where do I get a list of error-codes for deliver?
  • How do I call procmail right from fetchmail? I came over some options like ‘-f %F’ or ‘-d %T’ and tried them, even though I couldn’t find out what they really do, but still it failed.

I’m working on this for 2 weeks now and getting real frustrated, so every help is much appretiated.

Greetings

The way I do it is to have fetchmail deliver to a local mailbox via postfix. It’s just something like this in /etc/fetchmailrc:

poll "pop.example.com" proto POP3: user "fred" there with password "secret" is "fred" here ;

Normally this would to to /var/spool/mail/fred or /home/fred/Maildir/, depending on whether you have mbox or maildir format selected in postfix, but then .forward diverts this to procmail:

"|exec /usr/bin/procmail"

Then I have .procmailrc do the filtering and automatic filing to Maildir mailboxes (which is what I use). dovecot serves those Maildirs directly to mail programs.

PATH=/bin:/usr/bin
MAILDIR=$HOME/Mail          #you'd better make sure it exists
DEFAULT=$MAILDIR/mbox       #completely optional
LOGFILE=$HOME/.procmaillog  #recommended

# Whitelists

:0
* ^Subject: Cron
/home/fred/Mail/.cron/

etc.

Notice the trailing slash on the destination of the procmailrc recipe.

Spam filtering can be done in postfix.

Thanks for the help, works well this way.