Subject: procmail forwarding to multiple users

From: Don Westman <[email-masked]>
Date: Fri, 16 Sep 1994 12:37:04 -0400

I am just becoming aquainted with the power of procmail and am trying to see
if I can use it do a mini-listserver where specific incoming email messages
are forwarded to an internal distribution list.  The man pages for procmail
only shows how to forward to a single user.  What is the format to forward to
multiple users?  Can I use an existing .mailrc file defined alias to specify
the multiple users?  Please send responses directly to me as I'm not
currently a subscriber to the list.

Thanks for your help,
     Don Westman

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Donald Westman		Allen-Bradley Co.	Cleveland, Oh.
Internet: [email-masked]  ph: (216) 646-3645   fax: (216) 646-4343
	All views expressed herein are my own private views.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
WARNING: The U.S. Surgeon General may be hazardous to your health.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

---

From: [email-masked] (David W. Tamkin)
Date: Fri, 16 Sep 1994 14:58:52 -0500 (CDT)

Donald Westman wrote,

| The man pages for procmail only shows how to forward to a single user. 
| What is the format to forward to multiple users?

 :flags
 * conditions
 ! user1@site1 user2@site2 user3@site3 ...

| Can I use an existing .mailrc file defined alias to specify the multiple
| users?

No; mailx and Mail will recognize aliases in ~/.mailrc but when procmail
forwards mail, it feeds it directly to the system MTA named in $SENDMAIL.
It *will* recognize system aliases (those in /etc/aliases or /usr/lib/aliases
of /usr/lib/smail/aliases, whatever the file is named on your system).  If
you can set up an alias there with the list of names (or with an :include:
directive that pulls in a file where you have the names listed), you have
an alias that will work with procmail.

If you can't do that, but you want to keep the list of recipients somewhere
else, and it doesn't overflow $LINEBUF, you could do this:

 :flags
 * conditions
 ! `cat aliaslist`

The file containing the list must be named with a relative path from $MAILDIR
or with a full absolute path.

There are other ways, but these are the simplest to describe.

David W. Tamkin  P. O. Box 3284  Skokie IL  60076-6284
[email-masked]   MCI Mail: 426-1818   +1 312 714 5610

---

From: "J. Daniel Smith" <[email-masked]>
Date: Fri, 16 Sep 94 17:03:22 -0400

David W. Tamkin ([email-masked]) writes on 16 September 1994 at 14:58:52 -0500
>[...]

I've got a little script called "resend-message" that I use to do
this.  It needs some cleanup (the alias expansion is ugly), but it
works ok most of the time.  So you have something like
  :flags
  * conditions
  | resend-message joe.blow

   Dan
====================== message is author's opinion only ======================
J. Daniel Smith         Bristol Technology Inc., Ridgefield, Connecticut (USA)
[email-masked]         (203) 438-6969, 438-5013 (FAX)            
                        FTP: ftp.bristol.com     WWW: http://www.bristol.com
                                --------
 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
#

PATH=/bin:/usr/bin:/usr/local/bin

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" \
	-a"Subject: No subject given in original message!" \
	-a"To: $ADDRESS_LIST" \
  | exec /usr/lib/sendmail -t -oi "$ADDRESS_LIST"

exit 0