Jeronimo Zucco writes:
Hi list.
I'm trying to do my own maildrop script to do forward for outside
mails. I use a ldap attribute to store the mail address to forward. I
was using aliases in postfix, but this is a problem with SPF enabled
domains (SRS problem).
I did the following script to do mail forward:
/^To:.*/
getaddr($MATCH) =~ /^.*/;
MATCH=tolower($MATCH)
`FORWARD=$(ldapsearch -x -b 'ou=People,dc=domain,dc=com'
"(&(uid=$MATCH)(accountStatus=forward))" mailforward | grep
^"mailforward:" | cut -d\: -f2- | cut -d\ -f2- | sed -e
"s/[\\\`\\\\\$\(\)]//g" ) ; \
[ "${FORWARD}" ] && { cat - >/tmp/email_enc_${MATCH}$$.eml ; sendEmail
-q -f post...@domain.com -t ${FORWARD} -u "Forward Message" -a
/tmp/email_enc_${MATCH}$$.eml ; rm -f /tmp/email_enc_${MATCH}$$.eml;
exit 1 ; } `
if ( $RETURNCODE == 0 )
exit
But this script works only when the first "To:" mail address is the
user with forward enabled. If the message has more than one "to:"
address and it's not the first address, then mail forward don't work.
Some tip to get this work ? Any other way to solve mail forward with
SRS problem ?
The entire approach you take to solving your problem is completely unstable,
error prone, and will never work right. For the simple reason that the
contents of the To: header have absolutely nothing to do with this message's
recipients. I can easily send you an E-mail with the To: header set to
pres...@whitehouse.gov, so relying on the To: header for anything other
than some informative logging will never work right.
Any kind of forwarding processing belongs in the mail server, not the mail
delivery agent, like maildrop. That's where you need to do your forwarding.
The mail server knows who is the purported sender, and the recipients, and
can handle forwarding correctly. You will never do this correctly, with
maildrop. Forget it completely. Just drop the entire idea. It won't work.