Article View: comp.mail.misc
Article #817Re: Mail -> News gateway
From: Chip Salzenberg
Date: Wed, 22 Nov 1989 19:28
Date: Wed, 22 Nov 1989 19:28
207 lines
6349 bytes
6349 bytes
According to john@jwt.UUCP (John Temples):
>I'd like to be able to route incoming mail from a mailing list into a local
>newsgroup. Is there software available to do this? I tried using 'deliver'
>[... but:] my .signature gets appended to all of the articles, and when
>Rnmail is invoked via "R" from rn, it ignores the "Reply-To" header and
> sends the mail back to me. Any suggestions?
I earlier posted a version of my "del.news" script, which can be used with
Deliver to gateways mail to news. However, it had some faults. The version
I've enclosed below deals with:
Newsgroups, Distribution, Subject
From, Sender
Message-ID, References
Note that this script retains the mail's Message-Id. It also translates the
In-Reply-To header into a one-item References header, for use with modern
newsreaders.
It also changes the HOME directory of the inews program to somewhere that
it won't find a ".signature" file.
(Thanks to Bret Orsburn <bret@codonics.COM> for prodding me to fix the
From handling.)
This New and Improved del.news script, along with a sample post-user
delivery file that calls it, is sharchived below. If you use the enclosed
post-user file, mail to "news-newsgroup" is posted to "newsgroup".
Shar and enjoy.
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: del.p.news del.news
# Wrapped by chip@ateng on Wed Nov 22 14:16:12 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'del.p.news' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'del.p.news'\"
else
echo shar: Extracting \"'del.p.news'\" \(617 characters\)
sed "s/^X//" >'del.p.news' <<'END_OF_FILE'
X: del.p.news
X# A post-user delivery file to demonstrate news delivery.
X# Requires the "del.news" script.
X
X# Handle normal addresses, and accumulate newsgroup names.
X
XGROUPS=
X
Xfor u
Xdo
X case "$u" in
X news[\-\.]*)
X group=`echo $u | sed -e 's/^news.//' -e 'y/-/./'`
X if [ "$GROUPS" ]
X then
X GROUPS="${NEWSGROUPS},${group}"
X else
X GROUPS="${group}"
X fi
X ;;
X *)
X echo "$u"
X ;;
X esac
Xdone
X
X# Post to any newsgroup(s).
X
Xif [ "$GROUPS" ]
Xthen
X case "$DELFLAGS" in
X *[dA]*)
X # Dry Run
X echo >&2 "$0: post to $GROUPS"
X ;;
X *)
X /usr/local/lib/del.news local "$GROUPS"
X ;;
X esac
X
X echo DROP
Xfi
END_OF_FILE
if test 617 -ne `wc -c <'del.p.news'`; then
echo shar: \"'del.p.news'\" unpacked with wrong size!
fi
# end of 'del.p.news'
fi
if test -f 'del.news' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'del.news'\"
else
echo shar: Extracting \"'del.news'\" \(2265 characters\)
sed "s/^X//" >'del.news' <<'END_OF_FILE'
X: del.news
X# Shell script run by post-user delivery file.
X
Xif [ $# -ne 2 ]
Xthen
X echo >&2 "usage: $0 distribution newsgroups"
X exit 1
Xfi
X
XDIST="$1"
XGROUPS="$2"
X
X#-----------------------------------------------------------------------
X# Configuration
X#-----------------------------------------------------------------------
X
XMAILNAME=/usr/lib/news/mailname # C News -- mail name of org/host
XFAKEHOME=/usr/local/lib # Fake HOME for inews - no signature
X
X[ -s $MAILNAME ] && MHOST=`sed 1q $MAILNAME`
X[ "$MHOST" ] || MHOST=$HOST.UUCP
X
X#-----------------------------------------------------------------------
X# Figure out who is posting it.
X# That's the user name if local; otherwise, the Usenet owner.
X# Export this value as LOGNAME, so inews can use it.
X#-----------------------------------------------------------------------
X
Xcase "$SENDER" in
X*!*) LOGNAME=news ;;
X*) LOGNAME=$SENDER ;;
Xesac
Xexport LOGNAME
X
X#-----------------------------------------------------------------------
X# Generate the news article and feed it to inews.
X#-----------------------------------------------------------------------
X
X(
X # Newsgroups
X echo "Newsgroups: $GROUPS"
X
X # Distribution (if not world)
X [ "$DIST" = "world" ] || echo "Distribution: $DIST"
X
X # Subject
X header -n -f Subject $HEADER
X
X # From
X from=`header -f From $HEADER`
X case "$from" in
X *@*)
X echo "From: $from" ;;
X *)
X case "$SENDER" in
X *!*)
X u=`expr "$SENDER" : '.*!\(.*\)$'`
X h=`expr "!$SENDER" : '.*!\([^!]*\)![^!]*$'`
X case "$h" in
X *.*) ;;
X *) h="$h.UUCP" ;;
X esac
X ;;
X *)
X u="$SENDER"
X h=$MHOST
X ;;
X esac
X c=`expr "$from" : '.*\( ([^)]*)\).*$'`
X echo "From: $u@$h$c"
X ;;
X esac
X
X # Sender
X echo "Sender: usenet@$MHOST"
X
X # Message-ID (optional)
X x=`header -f message-id $HEADER`
X [ "$x" ] && echo "Message-ID: $x"
X
X # References (optional)
X x=`header -f in-reply-to $HEADER`
X x=`expr "$x" : '.*\(<[^>]*>\).*$'`
X [ "$x" ] && echo "References: $x"
X
X # Separator
X echo ""
X
X # Body (without gratuitous blank line at the end)
X sed '${/^$/d;}' $BODY
X) |
X HOME=$FAKEHOME /usr/lib/news/inews -h
X
X## Save a copy of the mail for debugging purposes
X#echo news:Posted
END_OF_FILE
if test 2265 -ne `wc -c <'del.news'`; then
echo shar: \"'del.news'\" unpacked with wrong size!
fi
chmod +x 'del.news'
# end of 'del.news'
fi
echo shar: End of shell archive.
exit 0
--
You may redistribute this article only to those who may freely do likewise.
Chip Salzenberg at A T Engineering; <chip@ateng.com> or <uunet!ateng!chip>
"Did I ever tell you the Jim Gladding story about the binoculars?"
Technical Details
Message-ID:
<256AF356.20842@ateng.com>Path:
arc1-ca.pugleaf.net!utzoo!utstat!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!ateng!chipReferences:
<476@jwt.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utstat!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!ateng!chip From: chip@ateng.com (Chip Salzenberg) Newsgroups: comp.mail.misc,news.software.b Subject: Re: Mail -> News gateway Message-ID: <256AF356.20842@ateng.com> Date: 22 Nov 89 19:28:20 GMT References: <476@jwt.UUCP> Organization: A T Engineering, Tampa, FL Lines: 207