I didn't see anything obvious in the list archives or associated man
pages on this:
I want to re-write the Subject: of messages using other header
criterion. I'm fetchmail(1)'ing a catch-all into a global account and I
want to tag message to virtual users in the Subject. Normally I would
just put them into sub-folders, but I'm feeling adventurous. I can
visual what I want to do in procmail, but not maildrop syntax; I want to
'tag' messages. I've manage to hack something ugly together that is
functional, but it exec's a lot of sub-shells and I'm almost certain it
could be done more efficiently.
I was very surprised to learn that reformail(1) doesn't have a macro for
'original header value' that i could use as an escape sequence (%orig,
etc.)
In fact, why do we even have to call an xfilter? Couldn't we use
maildrop's regex and variable assignment code to do string manipulation?
Thoughts?
---
VERBOSE=9
DEFAULT="$HOME/Maildir"
logfile "$HOME/mailfilter.log"
if ( /^(To|[Cc][Cc]): (noc|abuse|info|sales|help|support|etc).*/ )
{
LADDR = `echo $MATCH | sed 's/To://g'`
if ( /^Subject:.*/ )
{
LSUBJECT = `echo $MATCH | sed 's/Subject://g'`
}
xfilter "/usr/pkg/bin/courier/reformail -I'Subject: [$LADDR]
$LSUBJECT'"
to "$DEFAULT"
}