#!/bin/csh # ~/bin/.csh/mailto.holz by Julian Stacey set tmp_dir=~/mail/drafts # set name=`date +%Y_%m_%d_%H_%M_%S.mail.vi_tmp` # nice name, but generates files not seen by exmh # set name=`date +%Y%m%d%H%M%S$$` # Changed to a numeric to be mh compatible, but # exmh complains integer value too large to represent. set name=$$ # pid set file=$tmp_dir/$name set log=~/mail/outgoing.log mkdir -p $tmp_dir >& /dev/null # If $1 is set, use it as X Server display name. # system.fvwmrc uses this with rsh, # now my csh.cshrc no longer sets env var DISPLAY if ( $1.x == ".x" ) then #{ set DISP = "" # leave xterm to see if env var DISPLAY is set else # }{ set DISP = "-display $1" # assert X server name endif # } # next line used to cp instead of touch, # cp made it a more reliable beginning, # but it's more important not to trash previous drafts with same number # from a previous boot. touch $file # create if not existant echo "CONSIDER ABORTING THIS & USING COMP BUTTON IN EXMH" >> $file echo "==================================================" >> $file echo " " >> $file cat ~/mail/components >> $file # cat in case pre-exists # On internal host, ~/.mail_forwcomps is a sym link to # ~/mail/forwcomps. On gate hosts it's just a file. # This avoids it being uploaded to my web space, # as I dont want my email address harvested by spammers. # echo "" >> $file # cat ~/.signature >> $file xterm \ -n mailto \ -T "`hostname` - Mailto" \ -g 80x40 \ $DISP \ -e /usr/bin/vi $file echo " " >> $log echo "START {" >> $log echo "Date: `date`" >> $log if ( "`filesize 0 == $file`.x" == .x) then #{ echo "~/bin/.csh/mailto.holz: Abandoning $file `ls -l $file`" >> $log cat $file >> $log # cat is redundant unless filesize fails to work properly, in which case # although the mail won't get sent, & you won't know, if the other person # happens to tell you they never received whatever they expected to, # at least you won't have to type it all again, as it'll be in $log. echo "STOP }" >> $log rm $file exit 1 else # }{ echo "~/bin/.csh/mailto.holz: Sending $file `ls -l $file`" >> $log sendmail -i -t < $file # -t Read message for recipients. To:, Cc:, and Bcc: lines will # be scanned for recipient addresses. The Bcc: line will be # deleted before transmission. Any addresses in the argument # list will be suppressed, that is, they will not receive # copies even if listed in the message header. # -i Ignore dots alone on lines by themselves in incoming mes- # sages. This should be set if you are reading data from a # file. cat $file >> $log echo "STOP }" >> $log rm $file exit 0 endif # }