Hello, might someone be able to help me? Here I am trying to create a small form mailer cgi, adapting it from a much larger file that currently works on my server. However, I am getting the dreaded error 500: premature end of script headers. sendit.pl
#!/bin/perl if ($ENV{'REQUEST_METHOD'} eq "GET") {$buffer = $ENV{'QUERY_STRING'};} elsif ($ENV{'REQUENT_METHOD'} eq "POST") {read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'});} $bufferb = $buffer; @forminputs = split(/&/, $bufferb); foreach $forminput (@forminputs) { ($name, $value) = split(/=/, $forminput); $value =~ tr/+/ /; $value =~ s/%([a-fA-f0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $in{$name} = $value; } print "Content-type: text/html\n\n"; #mail sent to admin open (LMAIL, "|usr/sbin/sendmail -t"); print LMAIL("To: $in{myEmail}\n"); print LMAIL ("From: $in{Email}\n"); print LMAIL ("Subject: $in{Form}\n"); print LMAIL ("--------------------\n\n"); print LMAIL("$in{Message}\n\n"); #mail sent to user open (MAIL, "|/usr/sbin/sendmail -t"); print MAIL<<toEnd; To: $in{Email} From: $in{myEmail} Subject: $in{Form} Thanks for your email! \n\n toEnd print MAIL ("\n.\n"); #submit screen print ("<html><head<title>$in{Form}</title></head>"); print ("<body bgcolor=\"ffffff\">"); print ("Thanks for your email."); print ("</body></html");
sendit.html
<html> <head><title>sendit test form</title></head> <body bgcolor="#FFFFFF"> <em>sendit test form</em> <form method="post" action="cgi-bin/sendit.pl"> <input type="hidden" name="myEmail" value="elizabeth.dahm@hope.edu"> <input type="hidden" name="Form" value="sendit test form"> <p>Name&nbsp; <input type="text" name="Name" size="25"> <p>Email&nbsp; <input type="text" name="Email" size="25"> <p>Message&nbsp; <textarea name="Message" cols="40" rows="2"></textarea> <p><input type="submit" name="send" value="send"> </body></html>
My code is by no means perfect, as I've all ready picked out 3 bugs and realized I had originally uploaded it as binary instead of ascii. While I am able to properly chmod sendit.pl I suspect there might be some trouble with the endline characters and QVT-Term. I thank you kindly. :)

In reply to form mail with post, getting "premature ending of script headers" by edahm

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.