This one has me stumped. I went back to my recipe for a simple
mail reflector for a small discussion group, but in testing (sending a
message to myself) I have hit a snag. Procmail says that sed is an
unknown command, except that it is there. I guess I'll have to include
all the gory details.
procmail 3.10 under SunOS 4.1.4; login shell: csh
echo $PATH
/homec/pobart/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin:/usr/games:/etc:/usr/etc:.
which sed
/usr/local/bin/sed
.procmailrc:
# SHELL and PATH for standardization and safety
SHELL=/bin/sh
PATH=$HOME/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin:/etc:/usr/etc
# Degree of verboseness when logging is in effect (on[yes]/off[no])
VERBOSITY=off
# Whether logging is to be performed (yes/no/all)
LOGGING=no
# Folder for dumping suspected spam into
SPAMFOLDER=IN.xdiscard
# My complete Internet address
MY_ADDR=pobart(_at_)access(_dot_)digex(_dot_)net
# Directory for recipe and log files
PMDIR=$HOME/.procmail
# My mail folders directory (use variable to allow switching later)
DIRMAIL=$HOME/mail
MAILDIR=$DIRMAIL
# sendmail
# SENDMAIL=/usr/lib/sendmail
# Path to logfile (if enabled)
LOGFILE=$PMDIR/log
# Set on when debugging, else off
VERBOSE=$VERBOSITY
# LOGABSTRACT yes/no controls logging
LOGABSTRACT=$LOGGING
# Specify where our recipes are
INCLUDERC=$PMDIR/rc.recipes
rc.recipes calls mailgoup.rc with INCLUDERC:
################################################################
# Implement a simple, manually-maintained mail reflector. #
# This recipe is only intended for a small, closed group. #
# There is no automatic subscribe or unsubscribe function. #
# There is no automatic archive retrieval from the backup. #
# Group mail must be sent to a specific name at my address. #
# Recipients are listed in the file designated by $USERLIST, #
# on one line, with mail addresses separated by comma and #
# a blank. Variables $MY_ADDR and $SPAMFOLDER are defined #
# earlier in the procmailrc hierarchy. Variables below may #
# Variables below may be changed as appropriate. #
################################################################
# Control logging for debugging purposes
VERBOSE=on
LOGGING=yes
GROUPNAME="glosa"
USERLIST="$HOME/$GROUPNAME/grouplist"
GROUPORG="GREGA_DICE_DE_GLOSA"
FULLNAME="$GROUPNAME <$MY_ADDR>"
MAILFILE="$HOME/$GROUPNAME/$GROUPNAME.archive.gz"
# If this is a list message, append a compressed copy to
# the archive file. Then have formail massage the message
# as needed. Note that $FULLNAME is not used in the
# conditions in order catch different address formats.
# Try to preserve essential MIME headers.
# Is it a potentially eligible submission?
:0 H
* $ ^TO$GROUPNAME
* $ ^TO$MY_ADDR
* $ ! ^X-List: *$GROUPNAME
* $ ! ^X-Loop: *$MY_ADDR
{
# It passed the first test for eligibility
# Find out whom it is from
:0
{ WHOFROM=`formail -XFrom: | formail -rtz -xTo:` }
# Pick off the subject for reuse
:0
* ^Subject: *\/[^ ].*
{ THESUBJ=$MATCH }
# Is this an eligible sender?
# (Have sed temporarily reformat the user file for egrep)
# (Note that placing "" across lines is deliberate)
NL="
"
:0 w
| sed -e "1,$/, /$NL/g" $USERLIST | egrep -is $WHOFROM $USERLIST
# ===== begin eligible submitter block =====
# Eligible submission: now reflect the mail
# to all members of the group
:0 a
{
# First append a copy of the message to the backup file
:0 c:
| gzip -9fc >> $MAILFILE
# Get the incoming message-id
:0
* ^Message-ID: *\/[^ ].*
{ MID=$MATCH }
# Get three MIME headers for preservation
:0
* ^Mime-Version: *\/[^ ].*
{ MIMEVER=$MATCH }
:0
* ^Content-Type: *\/[^ ].*
{ MIMETYPE=$MATCH }
:0
* ^Content-Transfer-Encoding: *\/[^ ].*
{ MIMEXFER=$MATCH }
# Have formail format the message for recipients
# (We call it Precedence: list merely as a convenience)
:0 fw
| formail -rz -I "Cc:" \
-I "Reply-To: $FULLNAME" \
-I "Subject: $THESUBJ" \
-I "X-List: $GROUPNAME" \
-I "X-Loop: $MY_ADDR" \
-I "X-Info: Private Discussion Group Only" \
-I "Precedence: list" \
-I "Message-ID: $MID" \
-I "Mime-Version: $MIMEVER" \
-I "Content-Type: $MIMETYPE" \
-I "Content-Transfer-Encoding: $MIMEXFER" \
-I "Errors-To: $MY_ADDR" \
-I "Return-Receipt-To:" \
-I "Resent-From: $FULLNAME" \
-I "Resent-Sender: $FULLNAME" \
-I "Organization: $GROUPORG"
# Send the mail out to all
:0 a
! `cat $USERLIST`
VERBOSE=$VERBOSITY
LOGABSTRACT=$LOGGING
}
# ===== end eligible submitter block =====
# If not eligible, send back a nastygram and store a copy
# for examination, thus terminating the outer recipe
:0 E
{
# When was it mailed?
:0
* ^Date: *\/[^ ].*
{ INDATE=$MATCH }
:0 c
| (formail -r -I"Precedence: junk" \
-I"X-Loop: $MY_ADDR"; \
echo "Your mail dated: $INDATE"; \
echo "and concerning Subject: $THESUBJ"; \
echo "was submitted to a private discussion group,"; \
echo "but you are not an eligible member of the group."; \
echo "--- Paul Bartlett <$MY_ADDR>" \
) | $SENDMAIL -oi -t
:0:
$SPAMFOLDER
VERBOSE=$VERBOSITY
LOGABSTRACT=$LOGGING
}
}
grouplist file for testing (only my address):
pobart(_at_)access(_dot_)digex(_dot_)net
incoming test message as it was captured before any "processing" recipes:
From pobart(_at_)access(_dot_)digex(_dot_)net Thu Jul 17 15:51:30 1997
Received: from localhost (pobart(_at_)localhost)
by access5.digex.net (8.8.4/8.8.4) with SMTP
id PAA13014 for <pobart(_at_)access(_dot_)digex(_dot_)net>; Thu, 17
Jul 1997 15:50:54 -0400 (EDT)
Date: Thu, 17 Jul 1997 15:50:53 -0400 (EDT)
From: Paul O Bartlett <pobart(_at_)access(_dot_)digex(_dot_)net>
X-Sender: pobart(_at_)access5(_dot_)digex(_dot_)net
To: glosa <pobart(_at_)access(_dot_)digex(_dot_)net>
Subject: Glosa List Test Message 17
Message-ID:
<Pine(_dot_)SUN(_dot_)3(_dot_)96(_dot_)970717155019(_dot_)13009A-100000(_at_)access5(_dot_)digex(_dot_)net>
Return-Receipt-To: pobart(_at_)access(_dot_)digex(_dot_)net
Organization: Express Access Private Account
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Glosa list test message 17.
Paul <pobart(_at_)access(_dot_)digex(_dot_)net>
----------------------------------------------------------
Paul O. Bartlett, P.O. Box 857, Vienna, VA 22183-0857, USA
Finger, keyserver, or WWW for PGP 2.6.2 public key
Home Page: http://www.access.digex.net/~pobart
verbose log:
procmail: [13016] Thu Jul 17 15:50:56 1997
procmail: Assigning "LOGGING=yes"
procmail: Assigning "GROUPNAME=glosa"
procmail: Assigning "USERLIST=/homec/pobart/glosa/grouplist"
procmail: Assigning "GROUPORG=GREGA_DICE_DE_GLOSA"
procmail: Assigning "FULLNAME=glosa <pobart(_at_)access(_dot_)digex(_dot_)net>"
procmail: Assigning "MAILFILE=/homec/pobart/glosa/glosa.archive.gz"
procmail: Match on
"(^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope|Apparently(-Resent)?)-To):(.*[^a-zA-Z])?)glosa"
procmail: Match on
"(^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope|Apparently(-Resent)?)-To):(.*[^a-zA-Z])?)pobart(_at_)access(_dot_)digex(_dot_)net"
procmail: Match on ! "^X-List: *glosa"
procmail: Match on ! "^X-Loop: *pobart(_at_)access(_dot_)digex(_dot_)net"
procmail: Executing "formail -XFrom: | formail -rtz -xTo:"
procmail: Assigning "WHOFROM=pobart(_at_)access(_dot_)digex(_dot_)net"
procmail: Assigning "MATCH="
procmail: Matched "Glosa List Test Message 17"
procmail: Match on "^Subject: *\/[^ ].*"
procmail: Assigning "THESUBJ=Glosa List Test Message 17"
procmail: Assigning "NL=
"
procmail: Executing " sed -e "1,$/, /$NL/g" $USERLIST | egrep -is $WHOFROM
$USERLIST"
sed: Unknown command
procmail: Assigning "LASTFOLDER= sed -e "1,$/, /$NL/g" $USERLIST | egrep -is
$WHOFROM $USERLIST"
procmail: Notified comsat: "pobart@: sed -e "1,$/, /$NL/g" $USERLIST | egrep
-is $WHOFROM $USERLIST"
So far I just have not figured out why procmail cannot find sed.
Note that I have written sed in this form because my sed (SysV,
apparently) does not recognize sed -e "s/, /$NL/g" $USERLIST
Thanks very much.
Paul <pobart(_at_)access(_dot_)digex(_dot_)net>
----------------------------------------------------------
Paul O. Bartlett, P.O. Box 857, Vienna, VA 22183-0857, USA
Finger, keyserver, or WWW for PGP 2.6.2 public key
Home Page: http://www.access.digex.net/~pobart