#!/usr/bin/perl ############################################################################### # formMail: Mail the content of an HTML form ############################################################################### $addr = 'sam.sultan@nyu.edu'; # setup recipient email address use CGI "param"; # use CGI param method @elementNames = param(); # get all FORM element names &mailData(); # Call mailData to e-mail &printHTML(); # Call printHTML to print HTML ############################################################################### # mailData: Mail content of the form fields ############################################################################### sub mailData { open(MAIL, "| /usr/sbin/sendmail $addr "); #pipe to unix sendmail command print (MAIL "Subject: Form Element Content \n"); print (MAIL "\n"); print (MAIL "Your Form Elements and Values are:\n"); foreach $name (@elementNames) { # for each form field print MAIL "\n $name: "; # send name to mail cmd @values = param($name); # get the values of field foreach $value (@values) { # for each value print MAIL "$value "; # send value to mail cmd } } close(MAIL); } ############################################################################### # printHTML: Generate a simple output HTML page ############################################################################### sub printHTML { print "Content-type: text/html \n"; print "\n"; print " Thank you

Your request has been delivered

"; print ""; foreach $name (@elementNames) { # for each form field print "\n
$name:"; # print name @values = param($name); # get the values foreach $value (@values) { # for each value print "$value
"; # print to html page } } print "
"; } exit(0);