CCL Home Page
Up Directory CCL news2mail.pl
#!/usr/local/bin/perl -s

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

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

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

while() {
    if(/^Path: listproc.mail.cornell.edu!listproc!server/) {
	close(DATAFILE);
	close(OUTFILE);
	unlink($tmp_posting);
	unlink($tmp_inews);
	exit 0;
    } elsif (/^From:/) {
	print OUTFILE "Resent-From:     ",$gatewayaddress;
	print OUTFILE $_;
	($from,$sender) = split(' ',$_,2);
    } elsif (/^Reply/) {				
	$reply = 1;
	print OUTFILE $_;
    } elsif (/^\s+$/ && !$reply) {	# End of headers and no Reply to header
	print OUTFILE "Reply-to: $sender\n\n";
	$reply = 1;
    } else {
	print OUTFILE $_;
    }
}			       
close (OUTFILE);
system( "/usr/lib/sendmail $dest < $tmp_inews");

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


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