procmail
[Top] [All Lists]

Re: running simple mailing list via procmail?

1995-11-17 08:08:08
Jon Granrose writes on 16 November 1995 at 22:11:09
[...]
easily set up a mailing list using procmail and just have the people on the
list put some identifying word in the Subject or one of the other headers.
And then just have procmail forward that mail to everyone listed in a file
after adding a few X-Resent headers.  Sounds pretty simple, and I'msure I
[...]

Here's what I have that I think will come pretty close to what you are
looking for:

-----
#####
# the resend-message script lives in my own bin directory
PATH=/bin:/usr/bin:/usr/local/bin:/usr/ucb:$HOME/bin
SHELL=/bin/sh

# Nachrichten mailing list
# mallon(_at_)rzmain(_dot_)rz(_dot_)uni-ulm(_dot_)de
# listserv(_at_)vm(_dot_)gmd(_dot_)de: SUB/SIGNOFF GERMNEWS J. Daniel Smith
##### forward "nachrichten" onto intested persons
:0c
* ^Reply-To:.*German *News *<GERMNEWS@(vm.gmd.de|DEARN.BITNET)>
| resend-message nachrichten
:A:
toread/nachrichten
-----
"resend-message" is a shell script that expands aliases in
$HOME/.mailrc, add Resent-* headers, and then passes it on to
sendmail.

   Dan
--------------------- message is author's opinion only --------------------
J. Daniel Smith <DanS(_at_)bristol(_dot_)com>              
http://www.bristol.com/~dan
Bristol Technology Inc.                     +1 203 438 6969, 438-5013 (FAX)
Ridgefield, Connecticut (USA)                       
{info,jobs}(_at_)bristol(_dot_)com
                                 --------
Von guten Maechten wunderbar geboren, erwarten wir getrost, was kommen
mag.  Gott ist mit uns am Abend und am Morgen, und ganz gewiss an
jedem neuen Tag.   - Dietrich Bonhoeffer
-----
#!/bin/sh
#
# J. Daniel Smith
# 13 January 1994
#
# resend a mail message expanding aliases from $HOME/.mailrc first
#
# note that your FQDN is needed in for the Errors-To: header.  You can
# remove this header if you aren't forwarding mail from mailing lists;
# otherwise its VITAL you have this, w/o it the mailing list
# administrator will get email problems about addresses they know
# nothing about.
#

PATH=/bin:/usr/bin:/usr/local/bin:`dirname $0`

if [ $# != 1 ]; then
   echo "Usage: $0 recipients < message"
   exit 1
fi

#
# ugly alias expansion from $HOME/.mailrc.  Probably could be done a
# lot better, but this seems to work OK
#
ALIAS_LIST=""
ADDRESS_LIST="$1"
until [ "$ALIAS_LIST" = "$ADDRESS_LIST" ] ; do
  ALIAS_LIST="`echo "$ADDRESS_LIST"| sed -e 's/,/ /g' `"
  ADDRESS_LIST=""
    for ALIAS in $ALIAS_LIST ; do
      ADDRESS=`grep '^[         ]*alias[        ][      ]*'"$ALIAS"'[   ]' 
${HOME}/.mailrc |\
      sed      -e s/'^[         ]*alias[        ][      ]*'"$ALIAS"'[   ][      
]*'// |\
      sed -e s/'"'//g`
      if [ "$ADDRESS" ] ; then
        ADDRESS_LIST="$ADDRESS_LIST $ADDRESS"
      else
        ADDRESS_LIST="$ADDRESS_LIST $ALIAS"
#      for elm alias expansion use the following line instead of the previous.
#      ADDRESS_LIST="$ADDRESS_LIST "`elm -c "$ALIAS" | cut -f3 -d\ `
      fi
    done
  done
ADDRESS_LIST="`echo "${ADDRESS_LIST}" | sed 's/^ //' | sed 's/ /, /g'`"

#
# now forward on the message
#

# get the date in RFC822 format for insertion into some messages;
# the "Resent-Date:" field is copied from the "Date:" field on some systems.
# RFC1123 says "All mail software SHOULD use 4-digit years in dates..."
DATE=`date '+%a, %d %h %Y %H:%M:%S %Z'`

# assume use of "formail" since that makes things a lot easier
# apparently sendmail ignores "To:" in the presence of "Resent-To:"
formail -b \
        -IResent-From: -I "From " \
        -i"Resent-To: $ADDRESS_LIST" \
        -i"Resent-Date: $DATE" \
        -I"Errors-To: $LOGNAME(_at_)`fqdn`" \
        -a"Subject: No subject given in original message!" \
        -a"To: $ADDRESS_LIST" \
  | exec /usr/lib/sendmail -t -oi "$ADDRESS_LIST"

exit 0

<Prev in Thread] Current Thread [Next in Thread>