#!/usr/bin/perl
#
#
# smartlist-approve: a filter to take an email message sent to a smartlist
#                    moderator when a message is sent to the list,
#                    and repost it to the list with a Approved: header.
#
# By Alan Schwartz <alansz@cogsci.berkeley.edu> 1996
#
#
# Usage: pipe mail message to
#   smartlist-approve <list address>
#
# Example:  cat message | smartlist-approve recipes@gourmet.org
#

# Set this to point to where your sendmail program is located:
$sendmail='/usr/lib/sendmail';

# Set this to your email address as a moderator
$email='myaddress@myhost';

die "Usage: $0 <list-address>\n" unless ($list = $ARGV[0]);
die "Unable to call $sendmail\n" unless open(OUT,"|$sendmail $list");

# Print out the headers, except any escaped >From header
while (<STDIN>) {
  last if /^$/;
  print OUT unless /^>From/;
}

# Add the Approved: header and a blank line
print OUT "Approved: $email\n\n";

# Print the rest of the body
print OUT <STDIN>;
close OUT;

