Subject: Re: send mail to a list

From: Roman Czyborra <[email-masked]>
Date: Fri, 31 Mar 1995 15:50:46 +0200

> How can I forward all from apakabar to, say, 10 persons?

	:0 c
	*^^From apakabar
	! person1 person2 person3 person4 ....

> but send those with the word "hertadi" in the body to dev/null?

	:0 B
	* hertadi
	/dev/null

---

From: "J. Daniel Smith" <[email-masked]>
Date: Fri, 31 Mar 95 09:30:53 -0500

Roman Czyborra ([email-masked]) writes on 31 March 1995 at 15:50:46 +0200
>	! person1 person2 person3 person4 ....

I use the following "resend-message" hack, which will expand aliases
from ~/.mailrc and add Resent-* headers; giving
	:0 c
	*^^From apakabar
	| resend-message person1 person2 person3 person4 ....

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

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

exit 0