Subject: Re: Mail -> News recepies

From: Sridhar Venkataraman <[email-masked]>
Date: Sun, 30 Jan 1994 08:19:55 -0700 (MST)

On Sun, 30 Jan 1994 [email-masked] wrote:

> Has anybody used procmail as mail-to-news gateway ?

Not too hard if you think about it. As an illustration, I will provide 
the recipes (beware, it is very suboptimal! any optimal suggestions 
welcome!) I use for moderating soc.culture.indian.info.

-=-=-=
:2c:
^TOsoc-culture-indian-info
^Newsgroups:.*soc.culture.indian.info
info

	:Ach
	newsgroups=|formail -a "Newsgroups: soc.culture.indian.info" \
			    -x "Newsgroups:"
	:Ach
	subject=|formail -x "Subject:"
	:Ach
	date=|formail -x "Date:"
	:Ach
	from=|formail -x "From:"

	:Ach
	| (formail -r -t \
	-i "Received:" \
	-I "From: sci.info submissions <[email-masked]>" ; \
   	echo "From:\t\t$from\nDate:\t\t$date\nNewsgroups:\t$newsgroups\nSubject:\t$subject" ; \
	cat /usr/people/sridhar/misc/sciinfo/rec )| $SENDMAIL -t -oi 

	:Ac
	| formail -I "Apparently-To:" -I "To:" -i "Date:" \
		  -a "Newsgroups: soc.culture.indian.info" \
	  -I "Sender:"\
	  -I "Path:"\
	  -a "Organization: -" \
	  -a "Followup-To: soc.culture.indian" \
	  -I "Approved: [email-masked]" \
          -I "Received:" -I "Return-Path:" |  tail +2 | \
  procmail $HOME/misc/sciinfo/.procmailrc

	:Ah
	/usr/mail/sridhar

-=-=-=

My $HOME/misc/sciinfo/.procmailrc has some basic checks and dumps it using 
mh-style recipe in another directory. You can just replace the procmail 
invocation with a "inews -h" or "mailnews" (if you have Rich $alz's newsgate)
and implement proper checks for the headers and you have a good automated 
mail->news mechanism. Since I moderate the said group, I have to approve 
them before posting. But debug the recipe thoroughly using your local 
test group before letting it loose on the world at large. :-)

Sridhar.
-- 
Sridhar Venkataraman   ASU, Tempe, Arizona USA   [email-masked]

---

From: [email-masked] (J. Daniel Smith)
Date: Mon, 31 Jan 94 09:52:01 -0500

[email-masked] ([email-masked]) writes on 30 January 1994 at 08:29:19 -0600
>Has anybody used procmail as mail-to-news gateway ?
I've used it in a shell script (actually, I only use "formail")...the
following isn't perfect, but it gives you the general idea.

   Dan
==== message is author's opinion only -- it is not an official statement ====
J. Daniel Smith                                      Applicon, Inc.
(313) 995-6395, 995-6171 (FAX)                       Ann Arbor, Michigan (USA)
[email-masked] (Internet), AAACA1::DSMITH (SINet)
-----
----- /net/news/bin/sinetbb2news
-----
#!/bin/sh
#
# J. Daniel Smith
# 7 September 1993
#
# Primitive attempt to implement a mail to news gateway.  Right now
# only used for gatewaying SINet BBs into USENET news (thus some
# VMS-specific stuff)
#
# Mail message is on stdin, newsgroup is in $1
#

if [ $# != 1 ]; then
   echo "Usage: $0 newsgroup < article"
   exit 1
fi

NNTPSERVER=news.ann-arbor.applicon.slb.com
export NNTPSERVER
INEWS=/usr/news/bin/inews

cat > /tmp/m2n-1-$$

# extract useful fields from RFC822 headers
#TO=`cat /tmp/m2n-1-$$ | formail -xTo:`
#CC=`cat /tmp/m2n-1-$$ | formail -xCc:`
DATE=`cat /tmp/m2n-1-$$ | formail -xDate:`
RESENT_FROM=`cat /tmp/m2n-1-$$ | formail -xFrom:`

# remove RFC822 mail headers, leaving the VAX junk
formail +1 -f -ds cat < /tmp/m2n-1-$$ > /tmp/m2n-2-$$
SUBJECT=`formail -xSubj: < /tmp/m2n-2-$$`
rm /tmp/m2n-1-$$

# some messages to the BB now have RFC822 headers after the VAX
# headers, if they are there, use those instead...  But don't look too
# far into the message in case someone put a "From:" line in the message
# itself.  There's probably a better way to do this...
tail +6 /tmp/m2n-2-$$ > /tmp/m2n-3-$$
FROM=`head -7 /tmp/m2n-3-$$ | formail -xFrom:`
if [ "$FROM" ]; then
   formail -f -IMessage-Id: -ITo: -IIn-Reply-To: -ICc: < /tmp/m2n-3-$$ > /tmp/m2n-infile-$$
   rm /tmp/m2n-3-$$
else
   ORIG_FROM=`formail -xFrom: < /tmp/m2n-2-$$`
   FROM=`eval /usr/news/bin/fix-vms-address $ORIG_FROM`
   SUBJECT=`formail -xSubj: < /tmp/m2n-2-$$`

   (
   echo "From: $FROM"
   echo "Orig-From: $ORIG_FROM"
   echo "Subject: $SUBJECT"
   echo ""
   cat /tmp/m2n-3-$$
   rm /tmp/m2n-3-$$
   ) > /tmp/m2n-infile-$$
fi
rm /tmp/m2n-2-$$

formail -f -a"Date: $DATE" -a"Subject: $SUBJECT" \
	   -i"Newsgroups: $1" -I"Distribution: slb" \
	   -i"Organization: SINet BB to USENET gateway at Applicon" \
	   -i"Resent-From: $RESENT_FROM" \
	   -I"X-Posted-By: Dan's sinetbb2news script" \
	   -I"Approved: [email-masked] (J. Daniel Smith)" \
	   </tmp/m2n-infile-$$ | (rm /tmp/m2n-infile-$$; exec $INEWS)