home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume14 / rmail-uucp / part01 / rmail
Text File  |  1990-07-26  |  3KB  |  87 lines

  1. # /bin/rmail replacement
  2. #
  3. # We've got a UUCP only domain, running stock SVR2 and 3 mail, rmail, and mailx.
  4. # We happen to use UUNET as our domain address router, and have no domain
  5. # address capability here.
  6. #
  7. # Rumor has it that I'm supposed to install smail or sendmail or something
  8. # equally hideously large in place of the stock mail system in order to
  9. # handle the incoming domain addresses.  Furthermore, its seems that I'm
  10. # also supposed to toss out mailx.  This seemed much more reasonable.
  11. #
  12. # As far as I can tell, this works OK at this site.  The only drawback
  13. # is that if MAILXFIX is turned on, the mailx 'r' command will only
  14. # reply to the message author, since the To: line is renamed Raw-To:.
  15. #
  16. # Feel free to call this a kludge.  However, I couldn't have compiled,
  17. # let alone installed, the alternatives in less time than it took to
  18. # write this.  Especially since the MASTER happens to be a lowly 286
  19. # running Venix SVR2.  Don't laugh- its rock solid and does a better
  20. # job of handling 19200 baud (with 16550A's) than its 386 brethren.
  21. #
  22. DOMAIN=pcr.com        # Domain Nmae
  23. MASTER=pcrat        # UUCP host name that talks to outside world
  24. SLAVES="pcroe pcrok"    # List of UUCP sites that talk to MASTER 
  25. MAILXFIX=1        # 1==Fix addresses for mailx. 0==leave them along
  26. #
  27. # End of configuration
  28. #
  29.  
  30. #
  31. #    Convert domain addresses into bang addresses
  32. #
  33. a1=`echo "$1" | tr '[A-Z]' '[a-z]'`
  34. shift
  35. d=
  36. u=
  37. for SLAVE in $SLAVES
  38. do
  39.     case "$a1" in
  40.     $DOMAIN!*)        d=`expr $a1 : "$DOMAIN!\(.*\)"`;;
  41.     $MASTER.$DOMAIN!*)    d=`expr $a1 : "$MASTER.$DOMAIN!\(.*\)"`;;
  42.     $SLAVE.$DOMAIN!*)    u="$MASTER!"
  43.                 d=$SLAVE!`expr $a1 : "$SLAVE.$DOMAIN!\(.*\)"`;;
  44.     $SLAVE!*)        u="$MASTER!"; d="$a1";;
  45.     *@$DOMAIN)        d=`expr $a1 : "\(.*\)@$DOMAIN"`;;
  46.     *@$MASTER.$DOMAIN)    d=`expr $a1 : "\(.*\)@$MASTER.$DOMAIN"`;;
  47.     *@$SLAVE.$DOMAIN)    u="$MASTER!"
  48.                 d=$SLAVE!`expr $a1 : "\(.*\)@$SLAVE.$DOMAIN"`;;
  49.     esac
  50.     if [ "$d" != "" ]; then break; fi
  51. done
  52. if [ "$d" = "" ]; then d="$a1"; fi
  53.  
  54. #
  55. #    If MAILXFIX is enabled, fix 'From:' and 'To:' lines so that a
  56. #    mailx 'r' reply is possible.  The 'R' mailx command can't be
  57. #    used, because it insists on trying to construct the return
  58. #    address by following the "From XXX ... remote from YYY" chain
  59. #    that rmail creates.
  60. #
  61. #    On the 'From:' line, this involves deleting anything in ()'s.
  62. #    Also, if there's something in <>'s, it is the return address
  63. #    and everything else is deleted.  Ultimately, we end up with
  64. #    an address that looks like 'uunet!person@domain'.
  65. #
  66. #    Finally, since we MUST use the 'r' command to reply, and we
  67. #    don't generally want to send the reply to ourselves, we
  68. #    simply rename the 'To:' line to be 'Raw-To:'.  This has the
  69. #    desired affect, but means that group replies aren't possible.
  70. #    It would take considerably more medicine to wade thru the
  71. #    'To:' line, remove just our address, and fix the rest of the
  72. #    recipients address so that they are correct relative to us.
  73. #
  74. if [ $MAILXFIX = 0 ]
  75. then
  76.     exec    /bin/mail "$d" $@
  77. else
  78.     exec    sed    -e 's/^From:\(.*\)/From:\1\
  79. Raw-From:\1/' \
  80.         | sed    -e 's/^From:.*<\(.*\)>/From: \1/' \
  81.             -e 's/^From:[     ]*\(.*\)(.*)/From: \1/' \
  82.             -e 's/^From: \(.*\)/From: '$u'\1/' \
  83.             -e "s/^To:/Raw-To:/" \
  84.         | /bin/mail "$d" $@
  85.         # | (echo /bin/mail "$d" "$@"; cat)
  86. fi
  87.