"Steve Cary" <scary(_at_)airmail(_dot_)net> writes:
HI. I need to use procmail and/or formail to capture incoming email that is
always From one address, always sent To one address, and to varying CC
receivers. I need to take the original message, add text above it and
respond back to the CC receiver, not to the original From or To addresses. I
have managed to write it so it responds to the original sender, but
otherwise I am lost. Can anyone guide me through this? I would really
appreciate it. Steve
...
I need to respond back to the CC line with new text in the body and the
original text below it.
The subject line needs to be the original subject line with text added ahead
of the original text. "new text here - original text here"
If you know exactly which header fields contains the address of the new
recipient, then don't use the auto reply flag (-r). Instead, just rename
and extract the header fields explicitly:
# What's the address of this auto responder? For use in the
# From: and X-Loop: header fields.
AUTOADDR = "address(_at_)goes(_dot_)here"
# Is it To: and From: the correct addresses? Also, make sure
# we're not looping
:0
* ^From:.*fromaddr
* ^To:.*toaddr
* ! $ ^X-Loop: *$\AUTOADDR
{
# Extact the Subject:, trimming leading whitespace. If
# there's no match then we leave off the "-" too.
:0
* ^Subject:[ ]*\/[^ ].*
{
OLDSUBJ = " - $MATCH"
}
NEWSUBJ = "new text here${OLDSUBJ}"
# Build a new header and insert the new text at the top of
# the body. This looks ugly but can be broken into five
# parts:
# 1) Pass through any X-Loop: header fields and add our own
# 2) Drop the original To: header field, change the original
# Cc: into a To:, and extract it.
# 3) Delete the old From: and Subject: fields and insert
# our new ones, then extract them
# 4) Save the blank line at the end of the header to keep
# the contents of "new-body-file" from ending up in the
# header. The -k flag normally passes through the entire
# body, but since we're only filtering the header of the
# message in this recipe, it only saves the separator.
# 5) Insert the body text. This will appear above the original
# body.
# The -X options in parts (2) and (3) may seem unnecessary,
# but if there are _any_ -X or -x options, then formail will
# only print the fields so selected, even if you just added
# them.
:0 fhw
| formail -XX-Loop: \
-A"X-Loop: $AUTOADDR" \
-ITo: \
-RCc: To: \
-XTo: \
-I"From: autoresponder <$AUTOADDR>" \
-I"Subject: $NEWSUBJ" \
-XFrom: \
-XSubject: \
-k ; \
cat new-body-file
# Send the new message. If the previous recipe (the filter)
# failed then we should skip this as the message hasn't been
# rewritten to have the correct addresses, thus the 'a' flag.
:0 aw
! -t
}
Philip Guenther
Procmail Maintainer
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail