🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #31940

Re: Incoming List mail to News Gateway??

#31940
From: Mike Bostock
Date: Fri, 02 Oct 1998 00:00
127 lines
4538 bytes
howard@wdsec.com wrote in message ...
>
>In Article<36137EE1.62E7AFDB@fsg1.nws.noaa.gov>, <brianm@fsg1.nws.noaa.gov>
>writes:
>> I am on a couple of high volume mailing lists which do not have
>> USENET news groups. I really prefer to read news passively rather than
>> having my mail box fill up. I also like the threading and expiring of
>> messages offered by news...
<snip>

>Check the INN FAQ
>I believe there's a program called mail2news
>and also a perl script.


mail2news (/usr/doc/HOWTO/mini/mail2news) works well here but needed slight
modification to strip the Newgroup: line and Path: line when going from
news2mail2news.  Also needs References: line included so that threading
works.

I know nothing about programming (Perl or anything else) but modified the
file as below (my additions are annotated MTB).  If someone else can improve
on it I would be grateful.

-------------------------------------------------------------------------
#!/usr/bin/perl

($program = $0) =~ s%.*/%%;

#( $version  ) = $] =~ /(\d+\.\d+).*\nPatch level/;
#die "$program: requires at least version 3 of perl\n"
#        if $version < 3;

#$inews = "/usr/bin/inews";
#$iopts = "-h -o \"mail2news gateway\"";
$inews = "/usr/bin/rnews";
$iopts = "";
$postinghost = "news.domain.com";



if ($#ARGV < 0) {
    # $newsgroup = "test";
    # we'll expect the newsgroup line in the body
} elsif ($#ARGV == 0) {
    $newsgroup = $ARGV[0];
} else {
    die "usage: $program [newsgroup]\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";

# header munging loop
while (<STDIN>) {
last if /^$/;

# Remove existing newsgroup and path lines otherwise INN objects
# if it sees two (ie news2mail2news) - MTB
s/^Newsgroups//;
s/^Path//;

# transform real from: line back to icky style
s/^From:\s+(.*) <(.*)>/From: $2 ($1)/;

s/Message-Id/Message-ID/;

# 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 INEWS

if
/^(Date|From|Subject|Path|Newsgroups|Organization|Message-ID|References):/i;
#if /^(Date|From|Subject|Path|Newsgroups|Message-ID):/i;
$saw_subject |= ( $+ eq 'Subject' );

$saw_msgid |= ( $+ eq 'Message-ID' );

$saw_newsgroup |= ( $+ eq 'Newsgroups' );

# might need this later to do something useful with the References: line,
# so I'll put it in now - MTB

$saw_ref |= ( $+ eq 'References' );

}

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;

$approved = $newsgroup;
$approved =~ s/\./'-'/eg;

($sec,$min,$hour,$mday,$mon,$year)=localtime(time);
$madeupid = "\<$year$mon$mday.$hour$min$sec.$$\@domain.com\>";

printf INEWS "Newsgroups: %s\n", $newsgroup if $newsgroup;
printf INEWS "Approved: %s\@domain.com\n", $approved;
print  INEWS "Subject: Untitled\n" unless $saw_subject;
printf INEWS "Message-ID: %s\n", $madeupid unless $saw_msgid;
printf INEWS "NNTP-Posting-Host: %s\n", $postinghost;
print  INEWS "Organisation: (mail2news gateway)\n";
# Add References to aid threading - MTB
print  INEWS "References: \n";
print  INEWS "\n";

print INEWS while <STDIN>;   # gobble rest of message

close INEWS;
exit $?;
----------------------------------------------------------------------------
---------------




Technical Details
Message-ID: <6v3ff9$j9$1@wistaria.co.uk>
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
References: <36137EE1.62E7AFDB@fsg1.nws.noaa.gov> <NEWTNews.907276517.4815.howard@howardnt2>

Show Full Headers
Complete Article Headers
Message-ID: <6v3ff9$j9$1@wistaria.co.uk>
Subject: Re: Incoming List mail to News Gateway??
Date: Fri, 02 Oct 1998 00:00:00 +0000
From: "Mike Bostock" <dentist@pop.zynet.co.uk>
References: <36137EE1.62E7AFDB@fsg1.nws.noaa.gov> <NEWTNews.907276517.4815.howard@howardnt2>
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: 397171353
Cache-Post-Path: pluto!unknown@wistaria.zynet.co.uk
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3155.0
X-Complaints-To: postmaster@wistaria.co.uk
X-Trace: wistaria.co.uk 907362601 617 192.168.50.2 (2 Oct 1998 21:10:01 GMT)
Organization: Wistaria Dental Practice
NNTP-Posting-Date: 2 Oct 1998 21:10:01 GMT
Newsgroups: news.software.nntp