Although it's not a Postfix problem, I'd like to share the solution just
for completeness in the hope it might be useful.

Instead of setting sender and recipient as parameters, one should
forward it as arguments.

The whole thing now looks as follows:

The filter definition in Postfix' master.cf:
=====================================================================
procmail  unix  -       n       n       -       10       pipe
  flags=Rq user=vmail null_sender= argv=/usr/bin/procmail -m
/etc/procmailrc ${sender} ${recipient} ${domain}
=====================================================================
Whereas the "q" at flags is very important to get it working.

The /etc/procmailrc contains:
=====================================================================
SHELL=/bin/sh
E_SENDER=$1
E_RECIPIENT=$2
ER_DOMAIN=$3
SENDMAILFLAGS="-i -f $E_SENDER $E_RECIPIENT"
LOGFILE="/var/log/procmail"
VERBOSE=on

# First make a backup of the mail
:0c:
/var/mail/vhosts/backup-mail/$E_RECIPIENT/

# Scan for viruses
:0fw
| /usr/local/bin/clamassassin

# If no virus has been found, scan for Spam
:0fw
* ^X-Virus-Status: No
| /usr/bin/spamassassin

:0w
* !E_SENDER ?? (.)
| /usr/sbin/sendmail -i -f noreplay@$ER_DOMAIN $E_RECIPIENT

# Last action: inject back to Postfix
:0w
| /usr/sbin/sendmail $SENDMAILFLAGS
=====================================================================

E_SENDER=$1, E_RECIPIENT=$2 and ER_DOMAIN=$3 are assigning the command
line arguments.

"* !E_SENDER ?? (.)" checks if the variable "E_SENDER" is empty. If it
is empty, we need to adopt the Sendmail command.

If "!E_SENDER ?? (.)" evaluates to true, the Procmail execution ends
after invoking Sendmail, otherwise it executes the last action.

HTH,
Michael

Reply via email to