quissett has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I am looking for a little help in emailing the results of the form below to specific recipients. Specifically one of the recipients will need to receive the form base on the value of a field. In the case of the code below, I need the form sent to test@test.edu if the print MAIL "<font color=\"#FF0000\"><b>US Citizen? </b>$FORM{'ckusyes'} $FORM{'ckusno'}</font><br>"; check box value is 'chusno'
I know that I have to move where I put open (MAIL, "|$mailprog $recipient") || die "Can't open $mailprog!\n"; but I have not had any success in this endeavor. Please help....
#!/usr/local/bin/perl -- -*-perl-*- # ------------------------------------------------------------ # check-in.cgi # Interactive form # # ------------------------------------------------------------ # Define mail program $mailprog = '/usr/lib/sendmail'; # Recipient of form responses $recipient = 'hd@whoi.edu'; # Print out a content-type for HTTP/1.0 compatibility print "Content-type: text/html\n\n"; # Get the input read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Split the name-value pairs @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); # Un-Webify plus signs and %-encoding $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; # Stop people from using subshells to execute commands # Not a big deal when using sendmail, but very important # when using UCB mail (aka mailx). # $value =~ s/~!/ ~!/g; # Uncomment for debugging purposes # print "Setting $name to $value<P>"; $FORM{$name} = $value; } # Print title and header info for user response &user_response; $date = `date`; # Now send mail to $recipient formatted in HTML # Note: MIME, Subject and Content lines must appear EXACTLY as they do + below # (only one \n after Subject line!) open (MAIL, "|$mailprog $recipient") || die "Can't open $mailprog!\n"; print MAIL "Reply-to: $FORM{'espr2'} $FORM{'estb'} $FORM{'espr'}\n"; print MAIL "MIME-Version: 1.0\n"; print MAIL "To: $recipient\n"; print MAIL "From: $FORM{'espr2'} $FORM{'estb'} $FORM{'espr'}\n"; print MAIL "Subject: ES Internal Routing Form> $FORM{'name'}: $FORM{'i +d'} \n"; print MAIL "Content-Type: text/html; charset=us-ascii\n"; print MAIL "Content-Transfer-Encoding: 7bit\n"; print MAIL "<html><head>\n"; print MAIL "<title>WHOI Human Resources Office: "; print MAIL "ES Internal Routing Form</title>\n"; print MAIL "</head>\n"; print MAIL "<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#003366\ +" "; print MAIL "alink=\"#666666\" vlink=\"#6699CC\">\n"; print MAIL "<center><table border=0 width=99%>"; print MAIL "<tr><td align=left>"; print MAIL "<img src=\"http:///services/HR/graphics/smdbw_logo.gif\" " +; print MAIL "alt=\"WHOI logo\"></td>"; print MAIL "<td align=center><font color=\"#003366\" size=+2>"; print MAIL "Human Resources Office<br>"; print MAIL "ES Internal Routing Form</font></td></tr>"; print MAIL "</table>"; print MAIL "<img src=\"http:///services/HR/graphics/2lines.gif\" "; print MAIL "alt=\"2lines\"></center>"; print MAIL "<font color=\"#FF0000\"><b>Processed By: </b>$FORM{'espr2' +} $FORM{'estb'} $FORM{'espr'}</font><br>"; print MAIL "<b>Name: </b>$FORM{'name'}<br>"; print MAIL "<b>SS#: </b>$FORM{'ss'}<br>"; print MAIL "<b>ID#: </b>$FORM{'id'}<br>"; print MAIL "<b>Dept: </b>$FORM{'deptnumber'}<br>"; print MAIL "<b>Title: </b>$FORM{'title'}<br>"; print MAIL "<b>DOB: </b>$FORM{'dob'}<br>"; print MAIL "<font color=\"#FF0000\"><b>US Citizen? </b>$FORM{'ckusyes' +} $FORM{'ckusno'}</font><br>"; print MAIL "<b>If not, which country? </b>$FORM{'country'}<br>"; print MAIL "<b>Visa Type: </b>$FORM{'visa'}<br>"; print MAIL "<b>EEO Designation </b>$FORM{'eeodesgination'}<br>"; print MAIL "<b>Veteran: </b>$FORM{'eeoveteran'}<br>"; print MAIL "<b>Disabled: </b>$FORM{'eeodisabled'}<br>"; print MAIL "<hr>"; print MAIL "<font color=\"#003366\" size=+2><b>Employment Action </b>< +/font><br>"; print MAIL "<hr>"; print MAIL "<b>Action: </b>$FORM{'newhire'} $FORM{'rehire'} $FORM{'ter +m'} $FORM{'LOA'} $FORM{'change'} $FORM{'promotion'} $FORM{'extension' +}<br>"; print MAIL "<b>Dept Transfer To: </b>$FORM{'depttransfer'}<br>"; print MAIL "<b>Effective Date: </b>$FORM{'effectivedate'}<br>"; print MAIL "<b>Expiration Date: </b>$FORM{'expirationdate'}<br>"; print MAIL "<b>Termination Date: </b>$FORM{'terminationdate'}<br>"; print MAIL "<b>Termination Reason: </b>$FORM{'termreason'}<br>"; print MAIL "<hr>"; print MAIL "<b>Type/Status: </b>$FORM{'ft'} $FORM{'threequarter'} $FOR +M{'half'} $FORM{'casual'} $FORM{'education'} $FORM{'guest'}<br>"; print MAIL "<b>Reg/Temp: </b>$FORM{'regular'} $FORM{'temporary'}<br>"; print MAIL "<b>Graded/Exempt: </b>$FORM{'graded'} $FORM{'exempt'}<br>" +; print MAIL "<hr>"; print MAIL "<b>Annual Salary: </b>$FORM{'annsalary'}<br>"; print MAIL "<b>TRE: </b>$FORM{'tre'}<br>"; print MAIL "<b>Accrual Date: </b>$FORM{'accrualdate'}<br>"; print MAIL "<b>Supervisor: </b>$FORM{'super'}<br>"; print MAIL "<b>Office Address: </b>$FORM{'whoiadd'}<br>"; print MAIL "<b>Mail Stop: </b>$FORM{'ms'}<br>"; print MAIL "<b>Extension: </b>$FORM{'extension'}<br>"; print MAIL "<hr>"; print MAIL "<b>Primary Address: </b>$FORM{'primaryadd'}<br>"; print MAIL "<b>Primary Phone: </b>$FORM{'primaryphone'}<br>"; print MAIL "<b>Publish in the WHOI Directory? </b>"; print MAIL "$FORM{'pubaddry'} $FORM{'pubaddrn'}<br>"; print MAIL "<hr>"; print MAIL "<b>New Position: </b>$FORM{'newposition'}<br>"; print MAIL "<b>Job Code: </b>$FORM{'jobcode'}<br>"; print MAIL "<b>EEO Code: </b>$FORM{'eeocode'}<br>"; print MAIL "<b>Market Average: </b>$FORM{'marketave'}<br>"; print MAIL "<b>Additional Comments: </b>$FORM{'comments'}<br>"; print MAIL "<hr>"; print MAIL "<b>Emergency Contact: </b>$FORM{'emername'}<br>"; print MAIL "<b>Relationship: </b>$FORM{'emerrelate'}<br>"; print MAIL "<b>Emergency Address: </b>$FORM{'emeradd'}<br>"; print MAIL "<b>Emergency Phone: </b>$FORM{'emerphone'}<br>"; print MAIL "<hr>"; print MAIL "</body></html>"; close (MAIL);
Edit by castaway - added readmore tag
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: CGI recipient Option
by gellyfish (Monsignor) on Sep 01, 2004 at 16:15 UTC | |
by quissett (Initiate) on Sep 01, 2004 at 16:17 UTC | |
by ikegami (Patriarch) on Sep 01, 2004 at 16:22 UTC | |
by gellyfish (Monsignor) on Sep 01, 2004 at 16:24 UTC | |
Re: CGI recipient Option
by ikegami (Patriarch) on Sep 01, 2004 at 16:14 UTC | |
by quissett (Initiate) on Sep 01, 2004 at 16:22 UTC | |
by ikegami (Patriarch) on Sep 01, 2004 at 16:24 UTC | |
by quissett (Initiate) on Sep 01, 2004 at 16:36 UTC | |
by Anonymous Monk on Sep 01, 2004 at 17:30 UTC | |
Re: CGI recipient Option
by iburrell (Chaplain) on Sep 01, 2004 at 16:29 UTC | |
by quissett (Initiate) on Sep 01, 2004 at 16:52 UTC | |
by iburrell (Chaplain) on Sep 01, 2004 at 18:27 UTC | |
by quissett (Initiate) on Sep 01, 2004 at 20:06 UTC | |
by iburrell (Chaplain) on Sep 02, 2004 at 16:35 UTC | |
Re: CGI recipient Option
by iburrell (Chaplain) on Sep 01, 2004 at 18:30 UTC | |
Why reinvent the wheel?
by logan (Curate) on Sep 02, 2004 at 01:25 UTC |
Back to
Seekers of Perl Wisdom