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; }

In reply to passing CGI form parameters via HTML email by gmacfadden

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.