[news.software.nntp] sending a mail file to inews

dcox@ssd.kodak.com (Don Cox (253-7121)) (04/16/91)

Is it possible to send a mail file through inews and have it posted
to a newsgroup?  The following is a mail message I received:


From root  Mon Apr 15 16:35:12 1991
Date: Mon, 15 Apr 91 16:35:12 EDT
From: root (Super User)
To: dcox
Subject: meeting notice

Don,
[text deleted]


Suppose I wanted to post this message to kodak.junk.  Can inews accept
an input that doesn't have Newsgroup in the header?  Is there a way that
inews can get the Subject field and use that as the Subject for the
newsgroup?

Thanks much.

-- 
                  Don Cox
Phone (716) 253-7121      KMX (716) 253-7998
INTERNET    dcox@ssd.kodak.com

henry@zoo.toronto.edu (Henry Spencer) (04/16/91)

In article <1991Apr15.233624.11811@ssd.kodak.com> dcox@ssd.kodak.com (Don Cox (253-7121)) writes:
>Is it possible to send a mail file through inews and have it posted
>to a newsgroup? ...

It's possible but not trivial.  News needs more headers (e.g., Newsgroups)
and is fussier about the format of headers (e.g., parenthesized comments
are allowed in only one or two places).  You can't just feed mail into inews
and expect it to work reliably.
-- 
And the bean-counter replied,           | Henry Spencer @ U of Toronto Zoology
"beans are more important".             |  henry@zoo.toronto.edu  utzoo!henry

jgabriel@mtecv2.mty.itesm.mx (Juan Gabriel Ruiz Pinto) (04/17/91)

dcox@ssd.kodak.com (Don Cox (253-7121)) writes:

>Is it possible to send a mail file through inews and have it posted
>to a newsgroup?  The following is a mail message I received:

   Is not easy as just send the mail to inews and post it, the
  news articles need more headers, I use a perl script to change
  listserv mail articles for a local group to a newsgroup, next
  is the script, maybe it helps you. (if you have perl of course)

-----------------------------------------------------------------------
#! /usr/local/bin/perl -s
# Recibe articulos de BIT-CLUB via mail

$encontre = 0;
$lineas = -1;

while ( $linea = <> ) {
   if ( $linea =~ /^From:/ ) { 
      chop($linea);
      $linea_from = $linea unless $linea_from; 
   }
   elsif ( $linea =~ /^Path:/ ) {
      chop($linea);
      $path = $linea unless $path;
      @auxx = split(/ +/,$path);
      $path = join(" ",@auxx[1..$#auxx]);
      $path =~ y/A-Z/a-z/;
   }
   elsif ( $linea =~ /^Distribution:/ ) {
      chop($linea);
      $distribution = $linea unless $distribution;
   }
   elsif ( $linea =~ /^References:/ ) {
      chop($linea);
      $references = $linea unless $references;
   }
   elsif ( $linea =~ /^Subject:/ ) { 
      chop($linea);
      $linea_subject = $linea unless $linea_subject;
      @aux = split(/ +/, $linea_subject);
      $subject = join(" ",@aux[0..$#aux]);
   }
   elsif ( $linea =~ /^Date:/ ) { 
      chop($linea);
      $linea_date = $linea unless $linea_date;
   }
   elsif ( $linea =~ /^Organization:/ ) { 
      chop($linea);
      $linea_organization = $linea unless $linea_organization;
      @aux = split(/ +/, $linea_organization);
      $organization = join(" ",@aux[0..$#aux]);
   }
   elsif ( $linea =~ /^Message-Id:/ ) {
      chop($linea);
      @aux = split(/ +/, $linea);
      $messageid = join(" ",@aux[0..$#aux]) unless $messageid;
   }
   elsif ( $linea =~ /^Newsgroups: / ) {
      chop($linea);
      @aux = split(/ +/, $linea);
      $newsgroups = join(" ",@aux[0..$#aux]) unless $newsgroups;
   }
   elsif ( $linea =~ /^\n/ ) { 
      $encontre = 1; 
   }
   if ( $encontre ) {
     $lineas++;
     chop($linea);
     $texto[$lineas] = $linea;
   } 
}
   if ( $linea_from =~ />$/ ) {
      @from = split (/</, $linea_from);
      @aux = split(/ /, $from[0]);
      $nombre = join(" ",@aux[1..$#aux]);
      @aux = split(/>/, $from[1]);
      $origen = $aux[0];
   }
   else {
      @from = split (/ +/, $linea_from);
      $nombre = "sin nombre";
      $origen = $from[1];
   }


   if ( $origen =~ /%/ ) {
      @aux = split(/@/, $origen);
      @aux = split(/%/, $aux[0]);
      $origen = join("@",@aux[0..$#aux]);
   }


   @aux = split(/@/, $origen);
   $userid = $aux[0];
   @aux = split(/\./, $aux[1]);
   $nodo = $aux[0];
   $nodo =~ y/A-Z/a-z/;
 

   if ( !$path ) {
      if ( $nodo !~ /^mtecv2/i ) {
         $path = $nodo . "!" . $userid;
         $path =~ y/A-Z/a-z/;
      }
      else { 
         $path = $userid;
         $path =~ y/A-Z/a-z/;
      }
   }

   @aux = split (/ +/, $linea_date);
   $date = join(" ",@aux[2..$#aux]);

    if ( !$subject ) {
       $subject = "Subject: (sin titulo)";
    }

    if ( !$newsgroups ) {
       $newsgroups = "Newsgroups: itesm.bit-club";
    }
    $origen =~ y/A-Z/a-z/;
   
print <<EOT;
Path: $path
From: $origen ($nombre)
$newsgroups
$subject
$messageid
Date: $date
Approved: news@mtecv2.mty.itesm.mx
EOT
   if ( $organization ) {
      print "$organization\n";
   }
for ($i = 0; $i <= $#texto; $i++) {
   print "$texto[$i]\n";
} 
-- 
Juan Gabriel Ruiz Pinto                   Internet:
Ing. Sistemas Electronicos                jgabriel@mtecv2.mty.itesm.mx
I.T.E.S.M. Campus Monterrey

bdb@becker.UUCP (Bruce D. Becker) (04/20/91)

In article <1991Apr16.153753.2336@zoo.toronto.edu> henry@zoo.toronto.edu (Henry Spencer) writes:
|In article <1991Apr15.233624.11811@ssd.kodak.com> dcox@ssd.kodak.com (Don Cox (253-7121)) writes:
|>Is it possible to send a mail file through inews and have it posted
|>to a newsgroup? ...
|
|It's possible but not trivial.  News needs more headers (e.g., Newsgroups)
|and is fussier about the format of headers (e.g., parenthesized comments
|are allowed in only one or two places).  You can't just feed mail into inews
|and expect it to work reliably.

	I've been injecting a number of mail lists
	into news here for a while - I use a shell
	script that calls awk, which does the real
	work.

	This seems to be pretty reliable; the main
	problems are dup Message-ID's, or else the
	system running out of process slots...

-- 
  ,u,	 Bruce Becker	Toronto, Ontario
a /i/	 Internet: bdb@becker.UUCP, bruce@gpu.utcs.toronto.edu
 `\o\-e	 UUCP: ...!utai!mnetor!becker!bdb
 _< /_	 "Waking up is hard to do" - Neil Sedated

henry@zoo.toronto.edu (Henry Spencer) (04/20/91)

In article <90894@becker.UUCP> bdb@becker.UUCP (Bruce D. Becker) writes:
>|It's possible but not trivial.  News needs more headers (e.g., Newsgroups)
>|and is fussier about the format of headers...
>
>	I've been injecting a number of mail lists
>	into news here for a while - I use a shell
>	script that calls awk, which does the real
>	work.

A reasonable approach.  Does your shell/awk combo deal with things like
parenthesized comments where they aren't allowed in news?  The real test
of a gateway is how it copes with extreme cases, not whether it handles
the typical ones easily.  It's not as simple as it looks.
-- 
And the bean-counter replied,           | Henry Spencer @ U of Toronto Zoology
"beans are more important".             |  henry@zoo.toronto.edu  utzoo!henry

bdb@becker.UUCP (Bruce D. Becker) (04/22/91)

In article <1991Apr19.223903.28698@zoo.toronto.edu> henry@zoo.toronto.edu (Henry Spencer) writes:
|In article <90894@becker.UUCP> bdb@becker.UUCP (Bruce D. Becker) writes:
|>|It's possible but not trivial.  News needs more headers (e.g., Newsgroups)
|>|and is fussier about the format of headers...
|>
|>	I've been injecting a number of mail lists
|>	into news here for a while - I use a shell
|>	script that calls awk, which does the real
|>	work.
|
|A reasonable approach.  Does your shell/awk combo deal with things like
|parenthesized comments where they aren't allowed in news?  The real test
|of a gateway is how it copes with extreme cases, not whether it handles
|the typical ones easily.  It's not as simple as it looks.

	Well, I certainly have found that it isn't
	as simple as it looks, you're right there.
	The current version works because it's had
	fixes applied until it does, not because I
	RTFM. I've currently (until next week) got
	B news installed -  the case you mentioned
	hasn't yet arisen so it isn't implemented.
	B news seems to accept the "(" without any
	complaints so it actually converts "From:"
	lines to that style (perhaps incorrectly).
	When I go to C news, I can see that it may
	need to be fixed for that case, as well as
	as yet undiscovered others.  No doubt this
	is a familiar-sounding circumstance 8^)...

Cheers,
-- 
  ,u,	 Bruce Becker	Toronto, Ontario
a /i/	 Internet: bdb@becker.UUCP, bruce@gpu.utcs.toronto.edu
 `\o\-e	 UUCP: ...!utai!mnetor!becker!bdb
 _< /_	 "Waking up is hard to do" - Neil Sedated

henry@zoo.toronto.edu (Henry Spencer) (04/22/91)

In article <91014@becker.UUCP> bdb@becker.UUCP (Bruce D. Becker) writes:
>|... Does your shell/awk combo deal with things like
>|parenthesized comments where they aren't allowed in news? ...
>
>	B news seems to accept the "(" without any
>	complaints so it actually converts "From:"
>	lines to that style (perhaps incorrectly).

The From header is a specialized exception to the rule.
-- 
And the bean-counter replied,           | Henry Spencer @ U of Toronto Zoology
"beans are more important".             |  henry@zoo.toronto.edu  utzoo!henry