Bob Zeitz <Bob(_dot_)Zeitz(_at_)UAlberta(_dot_)CA> writes:
I am looking for a recipe that will return the message to
the sender and insert a few lines before the body of the
original message. I have found the example of how to
add content after the original message, but I want to
add a blurb _before_ the original message. I have read
the docs but I must be missing something.
This is not quite as easy to do, as in order to get a handle on the
header/body separation you have to 'filter' the body by itself, adding
your beginning-o'-body blurb then.
MYADDRESS = my-address(_at_)my(_dot_)site
:0 fb
* Whatever conditions on this taking place
* ! ^FROM_DAEMON
* $ ! ^X-Loop: $\MYADDRESS
| cat blurb -
:0A
| formail -rkA"X-Loop: $MYADDRESS" | $SENDMAIL -oi -t
As this requires procmail to be tossing around the entire body, I'd be
tempted to put a limit on how much of the body you send back, say, at
most 2k. Doing that is not easy unfortunately, as "head" can't take a
limit in characters, only lines. I suppose you could do it with 'dd',
but perl is nicer. Change the first action (the "| cat blurb -") to:
| cat blurb; perl -e 'read(STDIN, $foo, 2048);print "$foo ... [truncated]\n";'
If you do the above, a) make sure perl is in the path that procmail is using,
b) add the 'i' flag to the first recipe (making it begin ":0 fbi").
Philip Guenther