|
|
1.1 ! root 1: #!/bin/sh ! 2: # : Rnmail.SH,v 4.3.1.3 85/05/20 16:25:17 lwall Exp $ ! 3: # ! 4: # : Rnmail.SH,v $ ! 5: # Revision 4.3.1.3 85/05/20 16:25:17 lwall ! 6: # Shouldn't ask editor if EDITOR or VISUAL defined. ! 7: # ! 8: # Revision 4.3.1.2 85/05/17 10:36:19 lwall ! 9: # Added "-- " before .signature. ! 10: # ! 11: # Revision 4.3.1.1 85/05/10 11:30:38 lwall ! 12: # Branch for patches. ! 13: # ! 14: # Revision 4.3 85/05/01 11:34:18 lwall ! 15: # Baseline for release with 4.3bsd. ! 16: # ! 17: # ! 18: # syntax: Rnmail -h headerfile [oldart] or ! 19: # Rnmail destination-list or just ! 20: # Rnmail ! 21: ! 22: export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0; kill $$) ! 23: ! 24: # System dependencies ! 25: ! 26: mailer="/usr/lib/sendmail" ! 27: # if you change this to something that does signatures, take out signature code ! 28: ! 29: # your site name ! 30: case define in ! 31: define) sitename=`hostname` ;; ! 32: undef) sitename="ucbvax" ;; ! 33: esac ! 34: # your organization name ! 35: orgname="University of California, Berkeley" ! 36: # what pager you use--if you have kernal paging use cat ! 37: pager="${PAGER-/usr/ucb/more}" ! 38: # how you derive full names, bsd, usg, or other ! 39: nametype="bsd" ! 40: # default editor ! 41: defeditor="/usr/ucb/vi" ! 42: # how not to do a newline with echo ! 43: n="-n" ! 44: c="" ! 45: ! 46: test=/bin/test ! 47: sed=sed ! 48: echo=echo ! 49: cat=cat ! 50: grep=grep ! 51: rm=rm ! 52: ! 53: tmpart=/tmp/rnmail$$ ! 54: dotdir=${DOTDIR-${HOME-$LOGDIR}} ! 55: ! 56: headerfile="" ! 57: case $# in ! 58: 0) ;; ! 59: *) case $1 in ! 60: -h) ! 61: headerfile="$2" ! 62: case $# in ! 63: 3) oldart=$3 ;; ! 64: esac ! 65: ;; ! 66: esac ! 67: ;; ! 68: esac ! 69: ! 70: case $headerfile in ! 71: '') ! 72: case $# in ! 73: 0) ! 74: to=h ! 75: while $test "$to" = h ; do ! 76: $echo "" ! 77: $echo $n "To: $c" ! 78: read to ! 79: case $to in ! 80: h) ! 81: $cat <<'EOH' ! 82: ! 83: Type the net address of those people that you wish the message sent to. ! 84: Note that you will be asked later for additional addresses of people to ! 85: whom the message is not addressed but you wish to get copies. ! 86: ! 87: Separate multiple addresses with spaces. ! 88: ! 89: EOH ! 90: ;; ! 91: esac ! 92: done ! 93: ;; ! 94: *) ! 95: to="$*" ! 96: ;; ! 97: esac ! 98: to=`$echo "$to" | $sed 's/ */ /g'` ! 99: ! 100: title=h ! 101: while $test "$title" = h ; do ! 102: $echo "" ! 103: $echo $n "Title/Subject: $c" ! 104: read title ! 105: case $title in ! 106: h) ! 107: $cat <<'EOH' ! 108: ! 109: Type the title for your message. ! 110: EOH ! 111: ;; ! 112: esac ! 113: done ! 114: ! 115: # now build a file with a header for them to edit ! 116: ! 117: orgname=${ORGANIZATION-$orgname} ! 118: case $orgname in ! 119: /*) orgname=`$cat $orgname` ;; ! 120: esac ! 121: ! 122: $cat > $tmpart <<EOHeader ! 123: To: $to ! 124: Subject: $title ! 125: Organization: $orgname ! 126: Cc: ! 127: Bcc: ! 128: ! 129: EOHeader ! 130: ! 131: ;; ! 132: *) ! 133: $cat < $headerfile > $tmpart ! 134: ;; ! 135: esac ! 136: ! 137: ! 138: file=h ! 139: while $test "$file" = h ; do ! 140: $echo "" ! 141: $echo $n "Prepared file to include [none]: $c" ! 142: read file ! 143: case $file in ! 144: h) ! 145: $cat <<'EOH' ! 146: ! 147: If you have already produced the body of your message, type the filename ! 148: for it here. If you just want to proceed directly to the editor, type a ! 149: RETURN. In any event, you will be allowed to edit as many times as you ! 150: want before you send off the message. ! 151: EOH ! 152: ;; ! 153: '') ! 154: $echo "" >> $tmpart ! 155: state=edit ! 156: ;; ! 157: *) ! 158: $cat $file >>$tmpart ! 159: state=ask ! 160: ;; ! 161: esac ! 162: done ! 163: ! 164: $echo "" ! 165: ! 166: while true ; do ! 167: case $state in ! 168: edit) ! 169: rescue="sleep 1; $cat $tmpart >>${HOME-$LOGDIR}/dead.letter ; $echo saved in ${HOME-$LOGDIR}/dead.letter ; $rm -f $tmpart; exit" ! 170: trap "$rescue" 1 ! 171: trap : 2 ! 172: case "${VISUAL-${EDITOR-}}" in ! 173: '') ! 174: tmp=h ! 175: ;; ! 176: *) ! 177: tmp='' ! 178: ;; ! 179: esac ! 180: while $test "$tmp" = h ; do ! 181: $echo $n "Editor [${VISUAL-${EDITOR-$defeditor}}]: $c" ! 182: read tmp ! 183: case $tmp in ! 184: h) ! 185: $cat <<'EOH' ! 186: ! 187: Type a return to get the default editor, or type the name of the editor you ! 188: prefer. The default editor depends on the VISUAL and EDITOR environment ! 189: variables. ! 190: ! 191: EOH ! 192: ;; ! 193: '') ! 194: ;; ! 195: *) ! 196: VISUAL=$tmp ! 197: export VISUAL ! 198: ;; ! 199: esac ! 200: done ! 201: ${VISUAL-${EDITOR-$defeditor}} $tmpart $oldart ! 202: trap "$rescue" 2 ! 203: state=ask ! 204: ;; ! 205: ! 206: ask) ! 207: $echo "" ! 208: $echo $n "Send, abort, edit, or list? $c" ! 209: read ans ! 210: ! 211: case $ans in ! 212: a*) ! 213: state=rescue ! 214: ;; ! 215: e*) ! 216: state=edit ! 217: ;; ! 218: l*) ! 219: $pager $tmpart ! 220: state=ask ! 221: ;; ! 222: s*) ! 223: state=send ! 224: ;; ! 225: h*) ! 226: $cat <<'EOH' ! 227: ! 228: Type s to send the message, a to abort and append the message to dead.letter, ! 229: e to edit the message again, or l to list the message. ! 230: EOH ! 231: esac ! 232: ;; ! 233: ! 234: send) ! 235: if $test -f $dotdir/.signature; then ! 236: echo $n "Append .signature file? [y] $c" ! 237: read ans ! 238: case $ans in ! 239: ''|y*) ! 240: echo "-- " >> $tmpart ! 241: cat $dotdir/.signature >> $tmpart ! 242: ;; ! 243: esac ! 244: fi ! 245: case $mailer in ! 246: *sendmail) ! 247: $mailer -t <$tmpart ! 248: ;; ! 249: # but recmail does not know about Bcc, alas ! 250: *recmail) ! 251: $mailer <$tmpart ! 252: ;; ! 253: *) ! 254: set X `$sed <$tmpart -n -e '/^To:/{' -e 's/To: *//p' -e q -e '}'` ! 255: shift ! 256: set X "$@" `$sed <$tmpart -n -e '/^Cc:/{' -e 's/Cc: *//p' -e q -e '}'` ! 257: shift ! 258: set X "$@" `$sed <$tmpart -n -e '/^Bcc:/{' -e 's/Bcc: *//p' -e q -e '}'` ! 259: shift ! 260: $grep -v "^Bcc:" <$tmpart | $mailer "$@" ! 261: ;; ! 262: esac ! 263: case $? in ! 264: 0) ! 265: state=cleanup ! 266: ;; ! 267: *) ! 268: state=rescue ! 269: ;; ! 270: esac ! 271: ;; ! 272: rescue) ! 273: $cat $tmpart >> ${HOME-$LOGDIR}/dead.letter ! 274: $echo "Message saved to ${HOME-$LOGDIR}/dead.letter" ! 275: state=cleanup ! 276: ;; ! 277: cleanup) ! 278: $rm -f $tmpart ! 279: exit ! 280: ;; ! 281: esac ! 282: done
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.