This is the first time using procmail and I've got the following recipe,
SENDMAIL=/opt/zimbra/postfix/sbin/sendmail
SHELL=/bin/sh
PATH=$HOME/bin:/usr/bin:/bin:.
MAILDIR=/opt/zimbra/procmail/
DEFAULT=$MAILDIR
LOGFILE=.procmaillog
LOCKFILE=.procmaillock
VERBOSE=yes
#Get the recipient's address
TO_=`formail -xTo: \
| expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'`
#Get the recipient's local-part, e.g. fax number
FAXNO_=`echo "${TO_}" | awk -F@ '{ print $1 }'`
LOCALPART=${FAXNO_}
DOMAIN=faxservice.com
# Forward the email
:0
! ${LOCALPART}@${DOMAIN}
The recipe gets the TO email header, parses it and builds the forwarding email address.
PROBLEM
The problem with the recipe is that the email is rejected by the recipient because the Return-Path header is modified.
TRIED SOLUTIONS
I added the following to the top of the recipe,
SENDMAILFLAGS="-oi -f \"$SENDER\""
this makes the Return-Path header blank and the recipient still rejects the email.
I found this serverfault question and modified my recipe as follows,
# Forward the email :0 * ^Return-Path:[ ]*\/[^ ].+ { env=$MATCH } :0 ! ${env+-f "$env"} ! ${LOCALPART}@${DOMAIN}
procmail's log file shows an error that there is no match,
procmail: No match on "^Return-Path:[ ]*\/[^ ].+"
QUESTIONS
I don't know whether to make a change to the postfix pipe,
procmail-fax-send unix - n n - - pipe
flags= user=zimbra argv=/usr/bin/procmail /opt/zimbra/procmail/procmailrc
Or how to change my recipe, so that the original sender is not modified after procmail processes the email.