Despite researching this via Perldoc, the web, and my Perl texts over several days, I remain stumped. My simple objective is to successfully execute the CGI script identified by the form action="...." parameter when the form is embedded in an email (in lieu of the more usual HTML file.
I OBSERVE THAT THE FOLLOWING HTML FILE:
<html><head><title>Form data originating from HTML</title></head>
<body>
<form action="http://www.gmacfadden.com/cgi-bin/view_sent_form_data.cg
+i" method="POST">
Your Subject: <input type="text" name="subject"><br>
Your Comments: <textarea name="comments" rows="2" cols="15"></textarea
+><br>
<input type="submit" value="Send">
</form>
</body>
</html>
WORKS PERFECTLY WITH THE FOLLOWING PERL SCRIPT (LET'S CALL IT PERL SCRIPT #1)located at http://www.gmacfadden.com/cgi-bin/view_sent_form_data.cgi:
#!/usr/bin/perl -wT
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;
print header;
print start_html("View data from form executed in HTML email");
my $subject = param("subject");
my $comments = param("comments");
print "\$subject is $subject<br>\n";
print "\$content is $comments<br>\n";
print end_html;
THE CRUX OF MY QUESTION IS WHY DOES PERL SCRIPT #1 FAIL TO PROVIDE THE SAME EXPECTED RESULTS WHEN I EXECUTE THE FORM FROM WITHIN AN EMAIL (USING THE SAME INPUT DATA AND THE SAME EMBEDDED FORM AS IN THE HTML FILE)AS CREATED USING THE FOLLOWING PERL SCRIPT (LET'S CALL IT PERL SCRIPT #2)?
#!/usr/bin/perl -wT
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;
my $torecipients = "gmacfadden\@aol.com"; #substitur your email addre
+ss here
my $header1 = qq (Mime-Version:1.0);
my $header2 = qq (Content-type: text/html; charset="iso-8859-1");
my $content = qq(
<html><body><center>
<form enctype="multipart/form-data" action="http://www.gmacfadden.com/
+cgi-bin//view_sent_form_data.cgi" method="POST"><br>
Subject: <input type="text" name="subject"><br>
Comments: <textarea name="content" rows="2" cols="15"></textarea><br>
<input type="submit" value="Send">
</form></center></body></html>
);
print header;
print start_html("Create form within HTML E-Mail");
$ENV{PATH} = "/usr/sbin";
open (MAIL, "|/usr/sbin/sendmail -oi -t") or
&dienice("Can't fork for sendmail: $!\n");
print MAIL "$header1\n";
print MAIL "$header2\n";
print MAIL "To: $torecipients\n";
print MAIL "From: anybody\@anywhere.org\n";
print MAIL "Subject: Please complete the enclosed form\n\n";
print MAIL "$content\n";
close(MAIL);
print <<EndHTML;
<h2>The requested form data has been embedded in an email sent to you!
+ Thank you</h2>
EndHTML
print end_html;
sub dienice # The dienice subroutine handles errors.
{
my($errmsg) = @_;
print "<h2>Error</h2>\n";
print "<p>$errmsg</p>\n";
print end_html;
exit;
}