#!/usr/bin/perl #!/space/imail/perl/bin/perl # # NAME # M_EditSend - edit mail message and send it # # SYMOPSIS # M_EditSend recipient... # First, determine some things from the environment: # $editor = $ENV{"VISUAL"} || $ENV{"EDITOR"} || 'vi'; $shell = $ENV{"SHELL"} || '/bin/sh'; $home = $ENV{HOME} || '/tmp'; $dir = "$home/M/out"; $user = $ENV{USER} || $ENV{LOGNAME} || 'unknown'; ($host = `hostname`) =~ s/\s+$//; # Next, create a file to hold the message: # system "mkdir -p $dir" if (! -d $dir); ($sec,$min,$hour,$mday,$mon,$year) = localtime(time); $sitime = sprintf("%4d%02d%02d%02d%02d%02d",1900+$year,1+$mon,$mday,$hour,$min,$sec); $msg = "$dir/$sitime"; # Build message with SI time as name. # Now build the message: # open(R,">>$msg") || die "$0: Can't write \"$msg\" [$!]\n"; for $r (@ARGV) { # Copy recipients into message. print R "To: $r\n"; ++$ToLines; } print R "To: \n" if !$ToLines; print R "From: $user@$host\n"; print R "Subject: \n"; print R "\n"; while () {print R} close M; close R; close STDIN; # Fire up an xterm running the user's editor: # system "xterm -e $shell -c '$editor $msg'"; # Finally, mail off the message: # system "Msnd $msg"; # Note that we don't delete the reply. It is left in the folder, with # the 'e' suffix, in case we want to refer to it later. So far, little # is done with this fact, but it's there for later use.