\n"; }elseif(!isValidEmail($from_addr) && $from_addr !=''){ echo "You have not entered a valid from address
\n"; }elseif($cc_addr != '' && !isValidEmail($cc_addr)){ echo "You have not entered a valid cc address
\n"; }else{ //define path for mail log $mail_log = 'logs/mail/'.$mail_log; //set $header with params $header .= "To: $to_addr\n"; $header .= "Reply-To: $from_addr\n"; if($cc_addr != ""){ $header .= "CC: $cc_addr\n"; } $header .= "Subject: $msg_subj
\n\n"; $message .= "\n------Mail generated at ".date("M.d.Y H:m:s")."\n"; $tmp_file = "/tmp/phpTempMail".rand().".txt"; //echo $tmp_file."
"; //open a temporary file to write $header/$message $mail_file = fopen("$tmp_file", "w")or die("couldn't open file"); //write message and header to $mail_file fwrite($mail_file, $header . $message) or die("couldn't write to file"); //close $mail_file fclose($mail_file) or die("couldn't close file"); //execute postfix (aliased as sendmail) and send email //$uhoh = exec("/bin/cat $tmp_file | /usr/bin/sendmail -t"); $uhoh = exec("/bin/cat $tmp_file | /usr/sbin/sendmail -t"); //append log with new email exec("/bin/cat $tmp_file >> $mail_log"); if($uhoh == ''){ //delete the file from /tmp $return = exec("rm $tmp_file"); return TRUE; }else{ return FALSE; } } } ?>