On Fri, 12 Dec 1997, Scott Blomquist wrote:
Mail comes to a SmartMail list, and it has `Subject: Foobar quux'. I want
to change the subject so that it reads: `Subject: [Testlist] Foobar quux'
before shipping it out to the subscribers. If it already has `[testlist]'
or `[Testlist]' or `[TESTLIST]', I don't want to make any changes. If it
is a reply, I want to make sure the `[Testlist]' is between Re: and the
subject. If not, I want to add it: `Subject: Re: [Testlist] Foobar quux'.
Aside from running it thru a shell script, this is what springs to my
mind.
# See if it's a reply:
:0
* ^Subject:.*\<Re:\>
{ remarker=Re: }
# Match everything in the subject after any Re: and any [Testlist]:
# First condition gets what we don't want.
# Second condition gets everything after what we matched in first.
# If it wasn't a reply, remarker var does nothing.
:0
* ^Subject:\/.*([Testlist\])*(Re:[ ]*)*[ ]*
* ^Subject:${MATCH}\/.*
|formail -I"Subject: ${remarker:+${remarker} }[Testlist] $MATCH"
If your procmail script rebuilds the header somewhere else, you could
capture the second recipe's output into a variable instead of doing the
formail routine at that point.
{
subject="${remarker:+${remarker} }[Testlist] $MATCH"
option=I
}
Then in your later formail routine for outgoing mail:
formail -"${option:-a}""Subject: ${subject}"
If option and subject vars are not set the subject line is unchanged.
David Hunt