CCL Home Page
Up Directory CCL mail2news.pl
#!/usr/local/bin/perl

$tmp_posting = "/tmp/post2news.$$";
$tmp_inews = "/tmp/inews.$$";
$dest = $ARGV[0];
$gatewayaddress = "gateway\@newsstand.cit.cornell.edu";
$inews = "/inn/bin/inews";

open (INLIST, "cat >>".$tmp_posting." -|") || die "Foo. $!\n";
sleep(2);
close(INLIST);

open (DATAFILE, "<".$tmp_posting) || die "Bar. $!\n";
open (OUTFILE, ">".$tmp_inews) || die "Baz. $!\n";

while($line = ) {
    chop($line);
#    print STDOUT "$line\n";

    last if ($line =~ /^\s+$/);	  # Blank line means end of headers.

    ($head,$text) = split(": ",$line,2);
    $Headers{$head} = $text;
}

if (!$Headers{"Sender"}) {
    $Headers{"Sender"} = $gatewayaddress;
}

# Build up the news posting.

print OUTFILE "From: $Headers{'From'}\n";
print OUTFILE "Newsgroups: $dest\n";
print OUTFILE "Subject: $Headers{'Subject'}\n";
print OUTFILE "Path: mail-to-news\n";

while (($head,$text) = each %Headers) {
    if (($head ne "From") 
	&& ($head ne "Subject") 
	&& ($head ne "To")
	&& ($head ne "Received")) {
	print OUTFILE "$head: $text\n";
    }
}

print OUTFILE "\n";

while ($line = ) {
    print OUTFILE $line;
}

close (OUTFILE);
system( "$inews -h < $tmp_inews");

unlink($tmp_posting);
unlink($tmp_inews);


Modified: Wed Dec 23 18:09:00 1998 GMT
Page accessed 7924 times since Sat Apr 17 21:24:53 1999 GMT