Just thought I'd share this receipe.
The Original problem: Given a hundred users who email addresses have
moved from one company to another. ie user(_at_)A(_dot_)com to
user(_at_)B(_dot_)com(_dot_)
I needed to forward all messages to the new account and do an auto-reply
to the orignator, with an explaination and the new users email address.
So here it is....
# This gleens the user name from the To: field
# the puts it in the default $MATCH variable
# to be used later.
:0
* ^To: *\/[^ ].*[^ ]
{ }
# Sends an auto reply to the user and
# substitutes the users new email address
# for the placeholder in the vacation message.
:0 a
*!^FROM_DAEMON
*!^X-Loop:moveduser(_at_)Cadence(_dot_)COM
| ($FORMAIL -r -i"Precedence: junk" \
-A"X-Loop: moveduser(_at_)Cadence(_dot_)COM" ; \
sed "s:user:$MATCH(_at_)Cadence(_dot_)COM:" < $HOME/.vacation.msg \
) | /usr/lib/sendmail -t
*********************************
* Omar Keblawi *
* Email Postmaster - MITS *
* Cadence Design Systems, Inc. *
* (408) 944-6875 *
* keblawi(_at_)Cadence(_dot_)COM *
*********************************