PATH=/bin:/usr/bin:/usr/local/bin	# add more if appropriate
SHELL=/bin/sh

# list		should contain the submitting address of the list
# listreq	should contain the request address of the list
# subscribers	should name the file which contains the list of subscribers
#		separated by whitespace

:3wfh
!^Subject:.*((add|remove).*list|subscribe)
!^From +(postmaster|Mailer)
!^X-Loop: loop
| formail -b -IReturn-Receipt-To: -I"Errors-To: $listreq" \
  -I "Sender: $listreq" -I"Precedence: bulk" -IReceived: -I"X-Loop: loop"\
# -i "Reply-To: $list"			# uncomment if you want, many people
					# consider this a bad idea.

# If memberlist is longer than 2048 bytes, you will have to insert a
# LINEBUF=some_big_number here because procmail uses a buffer of size
# $LINEBUF to expand the inline 'cat'

:Aw
! -f$listreq `cat $subscribers`		# the -f and -oi are sendmail options
					# omit if not applicable
	# the -f flag will only take effect if the sender is not local

# Alternatively you could have put the burden on the shell for expanding the
# 'cat' by providing the following action line instead:
# | $SENDMAIL -oi `cat $subscribers`;	# the ; forces the procmail to pass
					# on the line to the shell unparsed

# Anything not delivered yet (either because it was from the postmaster
# or mailer-daemon, or because it might be a request-message) will be forwarded
# to the list maintainer:
:0w
! -oi $listreq

# In case not even this works, the mail will be appended to the
# following last-resort files

UMASK=666	# this is probably inevitable since procmail (in this case)
		# could be running under the local-sender's uid or the
		# daemon or mailer-uid (in the remote-sender's case)

DEFAULT=/tmp/${listreq}s		# first-choice
ORGMAIL=/var/tmp/${listreq}s		# a last-last-resort-file in case the
			# filesystem for /tmp/mylist-request should be full
