#!/usr/local/bin/perl # sends mail to all darpc people, who should be given on stdin ## in fact this is a general purpose mail-personaliser # writes ordinary paper mail and email # # mailer.p is an improvement on darpc.p # # mailer.p firstnamenumber=1 lastnamenumber=0 emailnumber=3 subject="Stat Phys Supervisions" file=messageM00 doit=1 < superviseM00 # $verbose = 1 ; $file = "null-file" ; $subject = "No Subject" ; # $doit = 0 ; # whether to send email $letter = 0 ; # whether to print out a letter too $address = "Darwin College" ; $topgap = 13 ; $bottomgap= 34 ; # was 10, 31, for courier16. $font = "Courier14" ; # # stdin should contain: (email, first name, other names) # example: $nocomplete=0 ; # whether to not autocomplete email addresses eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift; while ( <> ) { if (/\#|\= 0 ) { $firstname = $rest[$firstnamenumber] ; } else {$firstname ="" ; } if ( $lastnamenumber >= 0 ) { $lastname = $rest[$lastnamenumber] ; } else {$lastname ="" ; } $email = $rest[$emailnumber] ; $name = $firstname." ".$lastname ; if ( $email =~ /\@/ ) { # if it has cam in it or is long, leave it, or if it ends in a country if ( $nocomplete || $email =~ /\@.*cam/ || $email =~ /\@.+?\..+?\.+?/ || $email =~ /\@.+?\.hu/ ) { # do nothing } else { $email .= ".cam.ac.uk" ; } } else { $email .= "\@cam.ac.uk" ; } print $name , ": $email : \n" ; $greeting = "Dear $firstname, " ; $command = "echo \"$greeting\" | cat - $file | Mail -s \"$subject\" $email \n" ; print $command if ($verbose>2) ; if ($doit) { system $command ; } # if ($letter ) { # first page, cover $lfile = "\n"x$topgap . " "x10 . $name ."\n" . " "x10 . $address . "\n"x$bottomgap ; $lfile .= $greeting."\n" ; $tmpfile = "junktmp" ; open ( OUT , "> $tmpfile" ) ; print OUT $lfile ; close(OUT) ; system ( "cat $file >> $tmpfile" ) ; system ( "nenscript -p- -B -f $font $tmpfile | lpr -Pisduplex " ) ; } } } }