Jim Osborn wrote,
| FWIW, the goal of this little effort is to extract the From: address
| from a SmartList envelope and send each such address a form note.
I think, Jim, you're doing this the hard way. Since there are three ways
I can see of interpreting your question, I'll give an answer for each:
(1) If you just want to collect the return addresses from a folder, use
formail -rzxTo: -s < folder
formail -rtzxTo: -s < folder
if you want them figured using the -rt precedences.
(2) If what you want is all the From: addresses, whether those are the return
addresses or not,
formail -zxFrom: -s < folder
collects the From: addresses of all the messages in formail's stdin with
only one process, no pipes (except the one you might need for feeding
stdin to formail if it is being currently generated by another process),
and no extra shells.
(3) If you always want the From: address even if there is a Reply-To: [as per
#2] but you want to use formail -r to strip out comments, I got this to
formail -XFrom: -s formail -edrzxTo: -s < folder
It isn't really necessary to specify the -e and -d options: with only one
line of input each, the forked formails are going to have to act as if -e
and -d were in effect anyway. However, this still runs formail N+1 times
(where N is the number of messages in the input) instead of just once as
in #1 and #2, and I don't see a need to remove comments if each addressee
will get an individual mailing.
As to the general question of multiple commands on the output split by
formail -s, I don't know offhand, but since your example can be handled
without that, we don't need to figure it out yet.
I suppose that (being a ksh kind of guy), I'd attack it in a fashion like
formail -XFrom: -s < folder | ( date ; while read victim ; \
do Mail -s "You're in for it now" "$victim" < canned_text ; \
echo "$victim" ; \
done ; echo ) >> rogues_gallery
Between "do" and "done" you can reference $victim as many times as you like.