procmail
[Top] [All Lists]

Re: forwarding to many: will this work?

1997-06-27 12:39:00
On Fri, 27 Jun 1997 12:56:30 -0500, "Dennis A. Schmitz"
<den(_at_)lucent(_dot_)com> wrote:
:0
! 'cat fwdlist'
     ^           ^
You want backticks here.

Essentially, any unix utility which can call procmail for every line in
the forward list would work fine.

man sh -- look at the "while" loop.

Let me state up front that the best solution might just be to +ask+
your receipients if they would like to receive your messages in
cleartext, and keep those who do in a separate recipients file. Then
batch encrypt for the PGP crowd and send a single multi-encrypted
message to them all. Probably saves oodles of resources on both ends.
(The fact that somebody has a PGP key does not necessarily mean they
find it convenient to receive encrypted mail, particularly if it's not
more sensitive than that you are prepared to send it in cleartext to
some recipients.)

# forward mail
:0 c

I would simply write a trivial shell script at this point and feed the
message to that. Something like

    | $HOME/bin/pgp-forwarder $MyFwdList


... where the script might be something along the lines of

#!/bin/sh

case "$#" in
    1)
        ;;
    *)
        echo "$0: Want exactly one argument" >&2
        exit 1
esac

# You should probably set up a good PATH here

PATH=...

# We set these only if they are not already set.
# (Procmail should be providing us with nice default values.)
# Change the path to sendmail to what's right for you

SENDMAIL=${SENDMAIL:-/usr/lib/sendmail}
SENDMAILFLAGS=${SENDMAILFLAGS:--oi}

ORIG=/tmp/.$$.0
HEAD=/tmp/.$$.1
BODY=/tmp/.$$.2
ENCR=/tmp/.$$.3

trap "rm -f $ORIG $HEAD $BODY $ENCR" 1 2 3 5 15

# Save original message to a file

tee $ORIG | formail -A "X-Encryption: pgp -c" | sed -e '/^$/q' >$HEAD
sed -n '/^$/p' $ORIG > $BODY

while read recipient; do
        if
                # Encrypt the body for this recipient
                pgp -fea "$recipient" <$BODY >$ENCR

        then
                # Glue the header back on
                cat $HEAD $ENCR
        else
                cat $ORIG
        fi |

        # Send it off
        $SENDMAIL $SENDMAILFLAGS "$recipient"

        # If we were nice, we'd perhaps pause here
done <"$@"

rm -f $ORIG $HEAD $BODY


This is most emphatically untested but it might even work with only
minor tweaks. You need to test it with adult victims who approve of
your using them as guinea pigs.

Hope this helps,

/* era */

-- 
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r.  <http://www.iki.fi/~era/>
 * Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>