#!/usr/local/bin/perl

# change this to point to the cgi-bin library
require '/m/gopher/www/teletimes/teletimes.root/cgi-lib.pl';

# change this to the address to which you want the
# form contents mailed to
$to_address = '[email protected],[email protected]';

# change this to the subject that you want the message to have
$subject = 'Teletimes Form Results';

# change this to the pathname of a mail program that accepts
# the -s flag to specify a subject and takes a message from
# the standard input
$mailer = '/usr/lib/sendmail';

################################################################

# tell the client what type of file this is (HTML)
print &PrintHeader;

# print the HTML introduction
print "<HTML><HEAD><TITLE>Thank you</TITLE></HEAD><BODY>\n";
print "<IMG SRC=logo_small.gif><HR>\n";

# read form input variables into the `%in' array
&ReadParse;

# try to open a pipe to a mail program
if (open(OUT, "| $mailer $to_address")) {
 # make up a minimal mail header
 print OUT "To: $to_address\n";
 print OUT "Subject: $subject\n";
 print OUT "\n";

 # show the contents of each form field, if it has been
 # filled out or checked in some way
 foreach (sort keys %in) {
   print OUT "$_: $in{$_}\n" if ($in{$_});
 }

 # close the pipe to the mail program
 close(OUT);

 # thank the user
 print "Thank you for your comments.\n";
} else {
 # oops, something went wrong
 print "Sorry, your comments cannot be mailed at this time. Please try again later. [$!]\n";
}

# finish up the HTML
print "</BODY></HTML>\n";