Article View: news.software.nntp
Article #4113Re: Gate mail into News
From: Max Heffler
Date: Fri, 19 Jan 1996 00:00
Date: Fri, 19 Jan 1996 00:00
96 lines
3050 bytes
3050 bytes
In <4dci21$22c@mailgate.bender.com> "John J. Waterbury" <John.J.Waterbury@bender.com> writes:
>Is there any software available for easily gateing
>Mail into INN (ie: spooling mailining lists into NEWS to keep
>hundred of users from susbscribing to the same groups)?
I don't remember where I got the following script. I added the
inews.log stuff:
#!/usr/local/bin/perl
require "ctime.pl";
$log = "/home/max/.procmail/inews.log";
($program = $0) =~ s%.*/%%;
( $version ) = $] =~ /(\d+\.\d+).*\nPatch level/;
#die "$program: requires at least version 3 of perl\n"
# if $version < 3;
$inews = "/bin/inews";
$inews = "/usr/local/news/inews" unless -x $inews;
die "$program: can't find inews\n" unless -x $inews;
$iopts = "-h -S";
if ($#ARGV < 0) {
# $newsgroup = "test";
# we'll expect the newsgroup line in the body
} elsif ($#ARGV == 0) {
$newsgroup = $ARGV[0];
} elsif ($#ARGV == 1) {
$newsgroup = $ARGV[0];
$approval = $ARGV[1];
} else {
die "usage: $program [newsgroup] [approval]\n";
}
# in case inews dumps core or something crazy
$SIG{'PIPE'} = "plumber";
sub plumber { die "$program: \"$inews\" died prematurely!\n"; }
open (INEWS, "| $inews $iopts") ||
die "$program: can't run $inews\n";
open (LOG, ">> $log") ||
die "$program: can't open $log\n";
$ENV{'TZ'} = "CST6CDT";
print LOG &ctime(time);
# header munging loop
while (<STDIN>) {
last if /^$/;
# transform real from: line back to icky style
s/^From:\s+(.*) <(.*)>/From: $2 ($1)/;
# transform from_ line to path header; also works locally
s/^From\s+(\S+)@(\S+).*/Path: $2!$1/
|| s/^From\s+(\S+)[^@]*$/Path: $1\n/;
print LOG
if /^(From|To|Sender|Cc):/i;
print INEWS
if /^(From|Subject|Date|Path|Newsgroups|Organization|Message-ID):/i;
$saw_subject |= ( $+ eq 'Subject' );
$saw_newsgroup |= ( $+ eq 'Newsgroups' );
}
close LOG;
chmod 0666, $log;
warn "$program: didn't expect newsgroup in both headers and ARGV\n"
if $newsgroup && $saw_newsgroup;
die "$program: didn't get newsgroup from either headers or ARGV\n"
unless $newsgroup || $saw_newsgroup;
printf INEWS "Newsgroups: %s\n", $newsgroup if $newsgroup;
print INEWS "Subject: Untitled\n" unless $saw_subject;
printf INEWS "Approved: %s\n", $approval if $approval;
print INEWS "\n";
print INEWS while <STDIN>; # gobble rest of message
close INEWS;
exit $?;
Technical Details
Message-ID:
<max.822068573@utopia>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mailReferences:
<4dci21$22c@mailgate.bender.com>Show Full Headers
Complete Article Headers
Message-ID: <max.822068573@utopia> Subject: Re: Gate mail into News Date: Fri, 19 Jan 1996 00:00:00 +0000 From: max@utopia.texmicro.com (Max Heffler) References: <4dci21$22c@mailgate.bender.com> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail X-Deja-AN: 136038677 Distribution: inet Organization: Texas Microsystems, Inc. Newsgroups: news.software.nntp