<?php_track_vars?>
<?php

// Include common functions:

include ("common.inc");


// <--- Main Program --->

$aryConfig = array("to","subject","from","autofrom","autoprefix",
                    "autosubject","sendextras","autoextras",
                    "template","autoreply","log","askagain",
                    "required","checkfrom","logbodies",
                    "url_error","url_success");

 // Set blank variables to their defaults
 for ($c = 0; $c < count($aryConfig); $c++) {
    ${$aryConfig[$c]} = default_ifempty ($aryConfig[$c],${$aryConfig[$c]});
    if (empty (${$aryConfig[$c]})) {
       unset (${$aryConfig[$c]});
    }   // endif
 }   // endfor

 // Start branching depending on values...
 
if ( ( check_required($required,$aryMissing)) or (($checkfrom) and (strstr("$required",'from')) and (bad_address($from)) ) ) {
   Header("Location: $url_error");
} else { 
   if ($log) {
      log_it ($to, $from, $subject, $body);
      $logged = 1;
   }   // endif
   if ((!empty ($to)) or (!empty ($autofrom))) {
      mail_it ();
      $mailed = 1;
   }   // endif
   Header("Location: $url_success");
}   // endif (branching)
?>
