#!/usr/bin/perl
#
# print header stuff
#
print "Content-type: text/html", "\n\n";
print "<html>";
print "<body background=\"nevada.gif\">";
#
#define stuff to send email with
#is required for tripod sites to send e-mail
#
require TripodMail;
$mail = new TripodMail;
#
#define stuff to grab data entered on form
#is required for tripod sites to get information
#typed into form
#
require TripodCGI;
use CGI;
$cgi = new CGI;
#
#get users email address, subject of letter and letters text
#
#
# $formname name of disk file with model on how to send email
# this file must exist or we cant send the email
#
$formname=$cgi->param('formname');
$replyto=$cgi->param('replyto');
$frommail=$cgi->param('frommail');
$subject=$cgi->param('subject');
$text=$cgi->param('text');
$title=$cgi->param('title');
$file_prefix=$cgi->param('file_prefix');
$thefile=$cgi->param('thefile');
$debugflag=$cgi->param('debugflag');
if ($debugflag eq 'y' ) {
   print "debug_flag='$debugflag'<br>";
   print "formname='$formname'<br>";
   print "replyto='$replyto'<br>";
   print "frommail='$frommail'<br>";
   print "subject='$subject'<br>";
   print "text='$text'<br>";
   print "title='$title'<br>";
   print "the_file='$the_file'<br>";
   print "thefile='$thefile'<br>";
}
$errors=0;
if ( !  -e $formname ) {
   print "ERROR mail form file '$formname' does not exist<p>";
   print "ERROR to fix either<p>";
   print "<ol>";
   print "<li>Some idiot deleted the file $formname so someone must recreate the file";
   print "<li>The program has a bug and you must get the programmer to fix it.";
   print "</ol>";
   $errors++;
}
if ( !  -e $thefile ) {
   print "ERROR mail form file '$thefile' does not exist<p>";
   print "ERROR thats odd because the script that calls this program does a ls $filename<p>";
   print "ERROR your probably calling this program out of sequence<p>";
   $errors++;
}
#
#if the variable $text is null or blank
# its the 1st time the program has been run
# and we must display the form, or the 
# user has clicked on the submit button with
# out entering any text. againg we must display the
# form
if ($text =~ /^ *$/ ) {
   print "ERROR no text entered. \$text is blank<p>";
   $errors++;
}
if ($debugflag eq 'y' ) {
   print "validate user inputs<p>";
}
#if $text is not blank or null they entered
#some text they want to send as an email
#dont let them send the email if
#       $subject is blank
#       $from    is blank
#
$frommail=~s/ //g;
$replyto=~s/ //g;
if ($frommail =~ /^ *$/ ) {
  $errors++;
  print "You must enter a From: address<p>";
}
else {
  if ($frommail !~ /[^@]@[^@]/ ) {
    $errors++;
    print "From: address must contain an @ surronded by userid and server<p>";
    print "'$frommail' is invalid<p>";
  }
}
#
#if a Reply-To: address was entered valiate it
#
if ($replyto !~ /^ *$/i ) {
   if ($replyto !~ /[^@]@[^@]/ ) {
     $errors++;
     print "Reply-TO: address must contain an @ surronded by userid and server<p>";
     print "'$replyto' is invalid<p>";
   }
}
if ($subject =~ /^ *$/ ) {
  $errors++;
  print "You must enter a subject<p>";
}
if ($errors > 0 ) {
  print "you had errors!!!<p>";
  print "</html>";
  exit;
}
 open(BCC,$thefile) or print "ERROR cant open '$thefile'<p>";
 #
 # read in all the names to bcc
 #
 @bcc=<BCC>;
 close(BCC);
 #
 #for each name make a line that says
 #    BCC: name
 #
 if ( $replyto =~ /^ *$/ ) {
    $bcc="";
 }
 else {
    $bcc="Reply-To: $replyto\n";
 }
 $i=0;
 foreach $x (@bcc) {
   $i++;
   $bcc=$bcc."BCC: $x";
 }
 #
 # print the names in debug mode
 #
 if ($debugflag eq 'y' ) {
    print "bcc list=<p><pre>";
    print "$bcc";
    print "</pre>";
 }
 #
 #build the stinking hash which is used by
 #the tripod software to send the email
 #
 %hash = (
          'frommail', $frommail ,
          'bcc', $bcc ,
          'subject', $subject ,
          'text', $text 
         );
 #
 #use one stinking back slash for the \%hash
 #
 if ($debugflag eq 'y' ) {
    print "before sendmail<p>"; 
 }
 #
 #send the stinking email
 #
 $rc=$mail->sendMail($formname,\%hash);
 if ($rc == 1 ) {
    print "Mail has been sent to all email address in $thefile<br>";
    print "$i emails send<p>";
 }
 else {
    print "Error sending Mail to addresss in file $thefile<p>";
    print "Error rc=$rc <p>";
 }
 print "</html>";
 exit;

Visit the Crazy Atheist Libertarian
Check out "David Dorn" - Hate Monger
Check out Atheists United - Arizona
Visit my atheist friends at Heritics, Atheists, Skeptics, Humanists, Infidels, and Secular Humanists - Arizona
Arizona Secular Humanists
Paul Putz Cooks the Arizona Secular Humanist's Check Book
News about crimes commited by the police and government
News about crimes commited by religious leaders and beleivers
Some strange but true news about the government
Some strange but real news about religion
Interesting, funny but otherwise useless news!
Libertarians talk about freedom
Cool Useless Photos, Cool gif files, Cool jpg files
Legal Library
Gif, JPG, and other images you can use on your web pages
David Dorn Insuranse