John <webmaster(_at_)glock(_dot_)missouri(_dot_)edu> writes:
I have migrated from an old email address to a new one, and
would like Procmail to help out with a little problem . . .
I have no control over the old address, just that it is
forwarded to the new address. I am currently using procmail to
filter this (forwarded) email into a folder (named Old). But I want
to also send (a la vacation) a message back to the sender, telling
them the new email address and asking them to switch to it.
I would like to use something similar to Alan Stebbens'
correct-addr.rc, but need to implement this on the -new- server.
Also, I only want it to run under the rule set for the "Old" folder.
Well, assuming you've actually figured out that a given message had
been forwarded from the old address, you should extract the _envelope_
sender (as found in the Return-Path: and/or "From " headers) and
send your reply to that address:
# Avoid loops and then extract the envelope sender address
:0
* ! ^X-Loop: new(_at_)address
* 9876543210^0 ^Return-Path: *\/[^ ].*
* 9876543210^0 ^From +\/[^ ]+
{
FROM = $MATCH
# Extract the subject for the reply
SUBJECT = ""
:0
* ^Subject:\/.*
{ SUBJECT = $MATCH }
# Save only the X-Loop: headers from the old message
# (that'll help avoid multi-step loops). Add our own
# X-Loop: and set the To: and Subject:. The blank line
# from the echo separates the header and body. Then
# grab the body from the file "forwarded-message" in the
# current directory ($MAILDIR). Feed that all into sendmail,
# placing the address directly on the command line.
:0 hw
| ( formail
-A"X-Loop: new(_at_)address" -XX-Loop: \
-I"To: $FROM" -XTo: \
-I"Subject: Re: $SUBJECT" -XSubject: ; \
echo ""; \
cat forwarded-message \
) | $SENDMAIL $SENDMAILFLAGS -- "$MATCH"
}
Philip Guenther