v14i033: Domain Capable rmail for UUCP sites
Rick Richardson
rick at pcrat.UUCP
Fri Jul 27 09:50:03 AEST 1990
Posting-number: Volume 14, Issue 33
Submitted-by: rick at pcrat.UUCP (Rick Richardson)
Archive-name: rmail-uucp/part01
We recently registered a domain address, and suddenly began
getting domain addresses (e.g. rmail pcroe.pcr.com!rick) fed
to our circa SVR2 'rmail' which only groks 'rmail pcroe!rick'.
I had to quickly do something about this. Being the basically
lazy person that I am, I choose to replace '/bin/rmail' (which
used to be a link to '/bin/mail') with a shell script.
While I was in there, I figured I might as well fix things up
so that 'mailx' could reply with the 'r' command to the domain
addresses that are typically found in the 'From:' lines. You
can read about the meatball surgery in the comments.
So, if you have an aging 'Stock UNIX' relic for a mail system,
and are lazy like me, you might consider using this band-aid
replacement for rmail. What the heck, its only 3K, with comments.
What are sendmail/smail and the latest user-agent up to these days?
Also, this isn't recommended unless your domain is a terminal leaf.
-Rick Richardson
P.S. I'm a Minimalist (Hi Henry & Geoff, thanks for C news!),
and a Deist. What this means is that I believe that if God
intervenes at all, it is only minimally. In this case, I'm
quite sure that He did not lend a Hand.
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
# rmail
# This archive created: Wed Jul 18 12:08:52 1990
export PATH; PATH=/bin:/usr/bin:$PATH
if test -f 'rmail'
then
echo shar: "will not over-write existing file 'rmail'"
else
sed 's/^X//' << \SHAR_EOF > 'rmail'
X# /bin/rmail replacement
X#
X# We've got a UUCP only domain, running stock SVR2 and 3 mail, rmail, and mailx.
X# We happen to use UUNET as our domain address router, and have no domain
X# address capability here.
X#
X# Rumor has it that I'm supposed to install smail or sendmail or something
X# equally hideously large in place of the stock mail system in order to
X# handle the incoming domain addresses. Furthermore, its seems that I'm
X# also supposed to toss out mailx. This seemed much more reasonable.
X#
X# As far as I can tell, this works OK at this site. The only drawback
X# is that if MAILXFIX is turned on, the mailx 'r' command will only
X# reply to the message author, since the To: line is renamed Raw-To:.
X#
X# Feel free to call this a kludge. However, I couldn't have compiled,
X# let alone installed, the alternatives in less time than it took to
X# write this. Especially since the MASTER happens to be a lowly 286
X# running Venix SVR2. Don't laugh- its rock solid and does a better
X# job of handling 19200 baud (with 16550A's) than its 386 brethren.
X#
XDOMAIN=pcr.com # Domain Nmae
XMASTER=pcrat # UUCP host name that talks to outside world
XSLAVES="pcroe pcrok" # List of UUCP sites that talk to MASTER
XMAILXFIX=1 # 1==Fix addresses for mailx. 0==leave them along
X#
X# End of configuration
X#
X
X#
X# Convert domain addresses into bang addresses
X#
Xa1=`echo "$1" | tr '[A-Z]' '[a-z]'`
Xshift
Xd=
Xu=
Xfor SLAVE in $SLAVES
Xdo
X case "$a1" in
X $DOMAIN!*) d=`expr $a1 : "$DOMAIN!\(.*\)"`;;
X $MASTER.$DOMAIN!*) d=`expr $a1 : "$MASTER.$DOMAIN!\(.*\)"`;;
X $SLAVE.$DOMAIN!*) u="$MASTER!"
X d=$SLAVE!`expr $a1 : "$SLAVE.$DOMAIN!\(.*\)"`;;
X $SLAVE!*) u="$MASTER!"; d="$a1";;
X *@$DOMAIN) d=`expr $a1 : "\(.*\)@$DOMAIN"`;;
X *@$MASTER.$DOMAIN) d=`expr $a1 : "\(.*\)@$MASTER.$DOMAIN"`;;
X *@$SLAVE.$DOMAIN) u="$MASTER!"
X d=$SLAVE!`expr $a1 : "\(.*\)@$SLAVE.$DOMAIN"`;;
X esac
X if [ "$d" != "" ]; then break; fi
Xdone
Xif [ "$d" = "" ]; then d="$a1"; fi
X
X#
X# If MAILXFIX is enabled, fix 'From:' and 'To:' lines so that a
X# mailx 'r' reply is possible. The 'R' mailx command can't be
X# used, because it insists on trying to construct the return
X# address by following the "From XXX ... remote from YYY" chain
X# that rmail creates.
X#
X# On the 'From:' line, this involves deleting anything in ()'s.
X# Also, if there's something in <>'s, it is the return address
X# and everything else is deleted. Ultimately, we end up with
X# an address that looks like 'uunet!person at domain'.
X#
X# Finally, since we MUST use the 'r' command to reply, and we
X# don't generally want to send the reply to ourselves, we
X# simply rename the 'To:' line to be 'Raw-To:'. This has the
X# desired affect, but means that group replies aren't possible.
X# It would take considerably more medicine to wade thru the
X# 'To:' line, remove just our address, and fix the rest of the
X# recipients address so that they are correct relative to us.
X#
Xif [ $MAILXFIX = 0 ]
Xthen
X exec /bin/mail "$d" $@
Xelse
X exec sed -e 's/^From:\(.*\)/From:\1\
XRaw-From:\1/' \
X | sed -e 's/^From:.*<\(.*\)>/From: \1/' \
X -e 's/^From:[ ]*\(.*\)(.*)/From: \1/' \
X -e 's/^From: \(.*\)/From: '$u'\1/' \
X -e "s/^To:/Raw-To:/" \
X | /bin/mail "$d" $@
X # | (echo /bin/mail "$d" "$@"; cat)
Xfi
SHAR_EOF
chmod +x 'rmail'
fi
exit 0
# End of shell archive
--
Rick Richardson - PC Research, Inc., uunet!pcrat!rick, (201) 389-8963
More information about the Comp.sources.misc
mailing list