home *** CD-ROM | disk | FTP | other *** search
- # /bin/rmail replacement
- #
- # We've got a UUCP only domain, running stock SVR2 and 3 mail, rmail, and mailx.
- # We happen to use UUNET as our domain address router, and have no domain
- # address capability here.
- #
- # Rumor has it that I'm supposed to install smail or sendmail or something
- # equally hideously large in place of the stock mail system in order to
- # handle the incoming domain addresses. Furthermore, its seems that I'm
- # also supposed to toss out mailx. This seemed much more reasonable.
- #
- # As far as I can tell, this works OK at this site. The only drawback
- # is that if MAILXFIX is turned on, the mailx 'r' command will only
- # reply to the message author, since the To: line is renamed Raw-To:.
- #
- # Feel free to call this a kludge. However, I couldn't have compiled,
- # let alone installed, the alternatives in less time than it took to
- # write this. Especially since the MASTER happens to be a lowly 286
- # running Venix SVR2. Don't laugh- its rock solid and does a better
- # job of handling 19200 baud (with 16550A's) than its 386 brethren.
- #
- DOMAIN=pcr.com # Domain Nmae
- MASTER=pcrat # UUCP host name that talks to outside world
- SLAVES="pcroe pcrok" # List of UUCP sites that talk to MASTER
- MAILXFIX=1 # 1==Fix addresses for mailx. 0==leave them along
- #
- # End of configuration
- #
-
- #
- # Convert domain addresses into bang addresses
- #
- a1=`echo "$1" | tr '[A-Z]' '[a-z]'`
- shift
- d=
- u=
- for SLAVE in $SLAVES
- do
- case "$a1" in
- $DOMAIN!*) d=`expr $a1 : "$DOMAIN!\(.*\)"`;;
- $MASTER.$DOMAIN!*) d=`expr $a1 : "$MASTER.$DOMAIN!\(.*\)"`;;
- $SLAVE.$DOMAIN!*) u="$MASTER!"
- d=$SLAVE!`expr $a1 : "$SLAVE.$DOMAIN!\(.*\)"`;;
- $SLAVE!*) u="$MASTER!"; d="$a1";;
- *@$DOMAIN) d=`expr $a1 : "\(.*\)@$DOMAIN"`;;
- *@$MASTER.$DOMAIN) d=`expr $a1 : "\(.*\)@$MASTER.$DOMAIN"`;;
- *@$SLAVE.$DOMAIN) u="$MASTER!"
- d=$SLAVE!`expr $a1 : "\(.*\)@$SLAVE.$DOMAIN"`;;
- esac
- if [ "$d" != "" ]; then break; fi
- done
- if [ "$d" = "" ]; then d="$a1"; fi
-
- #
- # If MAILXFIX is enabled, fix 'From:' and 'To:' lines so that a
- # mailx 'r' reply is possible. The 'R' mailx command can't be
- # used, because it insists on trying to construct the return
- # address by following the "From XXX ... remote from YYY" chain
- # that rmail creates.
- #
- # On the 'From:' line, this involves deleting anything in ()'s.
- # Also, if there's something in <>'s, it is the return address
- # and everything else is deleted. Ultimately, we end up with
- # an address that looks like 'uunet!person@domain'.
- #
- # Finally, since we MUST use the 'r' command to reply, and we
- # don't generally want to send the reply to ourselves, we
- # simply rename the 'To:' line to be 'Raw-To:'. This has the
- # desired affect, but means that group replies aren't possible.
- # It would take considerably more medicine to wade thru the
- # 'To:' line, remove just our address, and fix the rest of the
- # recipients address so that they are correct relative to us.
- #
- if [ $MAILXFIX = 0 ]
- then
- exec /bin/mail "$d" $@
- else
- exec sed -e 's/^From:\(.*\)/From:\1\
- Raw-From:\1/' \
- | sed -e 's/^From:.*<\(.*\)>/From: \1/' \
- -e 's/^From:[ ]*\(.*\)(.*)/From: \1/' \
- -e 's/^From: \(.*\)/From: '$u'\1/' \
- -e "s/^To:/Raw-To:/" \
- | /bin/mail "$d" $@
- # | (echo /bin/mail "$d" "$@"; cat)
- fi
-