OK, I'm confused. I have this perl script (see below) that works just fine on one server. But I just tried it on another and I get an error 500. The log file tells me "Premature end of script headers". Can someone tell me what is causing this please? Thanks, here is the script (I'll post the html below the script just in case that helps).
#!/usr/bin/perl5 -w
use strict;
use CGI qwall);
use CGI::Carp qw(fatalsToBrowser);
# use Fcntl qwflock);
sub send_mail {
my($to, $from, $subject, @details)=@_;
my $sendmail="/usr/sbin/sendmail -t -oi";
open(MAIL, "|$sendmail") || die "Can't start sendmail: $!";
print MAIL<<END_OF_HEADER;
from: $from
to: $to
subject: $subject
END_OF_HEADER
print MAIL "Tournament entry request\n\n";
my $name = param("name");
print MAIL "$name\n";
my $address = param("address");
print MAIL "$address\n";
my $city = param("city");
print MAIL "$city,";
my $state = param("state");
print MAIL "$state ";
my $zip = param("zip");
print MAIL "$zip\n";
my $phone = param("phone");
print MAIL "$phone\n";
my $email=param("return_addr");
print MAIL "$email\n\n";
print MAIL "Member?\n";
my $member = param("member");
print MAIL "$member\n\n";
print MAIL "Please enter me into the following tournament(s)\n";
my $event = param("event");
print MAIL "$event\n\n";
print MAIL "Additional comments\n\n";
foreach (@details) {
print MAIL "$_\n";
}
print MAIL "\n";
close(MAIL);
}
print header;
my $return=param("return_addr");
if (! defined $return or ! $return) {
print "You must supply an email address<P>";
exit;
}
my $subject=param("subject");
if (! defined $subject or ! $subject) {
print "You must supply an subject<P>";
exit;
}
send_mail('mymail@mydomain.net',
$return,
$subject,
param("body"));
print "Mail sent.";
SCRIPT ENDS HERE
HTML BEGINS HERE
<b><CENTER>Woodbury Golf Course tournament entry form</CENTER></b><BR><BR>
Please complete all fields of the form. Thank you.<br><br>
Full name:<BR>
<INPUT name=name>
<BR>
<BR>
Address:<BR>
<Input name=address>
<BR>
<BR>
City:<BR>
<Input name=city>
<BR>
<BR>
State:<BR>
<Input name=state>
<BR>
<BR>
Zip:<BR>
<Input name=zip>
<BR>
<BR>
Phone:<BR>
<Input name=phone>
<BR>
<BR>
Your e-mail address:<BR>
<INPUT name=return_addr>
<BR>
<BR>
Are you a member?:<BR>
<INPUT type=radio value=yes name=member>Yes
<INPUT type=radio value=no name=member>No
<BR>
<BR>
Subject:<BR>
<INPUT value="Tournament entry" name=subject>
<BR>
<BR>
I wish to register for:<BR>
<INPUT type=radio value=Scratch name=event>Scratch (September 10)
<INPUT type=radio value=Handicap name=event>Handicap (September 17)
<INPUT type=radio value=Both name=event>Both events
<BR>
<BR>
Please enter any additional information (including handicap if known and entering handicap event):<br>
<TEXTAREA name=details rows=10 wrap=hard cols=40></TEXTAREA>
<BR>
<BR>
<INPUT type=submit value=Send Message?> </FORM>
#!/usr/bin/perl5 -w
use strict;
use CGI qwall);
use CGI::Carp qw(fatalsToBrowser);
# use Fcntl qwflock);
sub send_mail {
my($to, $from, $subject, @details)=@_;
my $sendmail="/usr/sbin/sendmail -t -oi";
open(MAIL, "|$sendmail") || die "Can't start sendmail: $!";
print MAIL<<END_OF_HEADER;
from: $from
to: $to
subject: $subject
END_OF_HEADER
print MAIL "Tournament entry request\n\n";
my $name = param("name");
print MAIL "$name\n";
my $address = param("address");
print MAIL "$address\n";
my $city = param("city");
print MAIL "$city,";
my $state = param("state");
print MAIL "$state ";
my $zip = param("zip");
print MAIL "$zip\n";
my $phone = param("phone");
print MAIL "$phone\n";
my $email=param("return_addr");
print MAIL "$email\n\n";
print MAIL "Member?\n";
my $member = param("member");
print MAIL "$member\n\n";
print MAIL "Please enter me into the following tournament(s)\n";
my $event = param("event");
print MAIL "$event\n\n";
print MAIL "Additional comments\n\n";
foreach (@details) {
print MAIL "$_\n";
}
print MAIL "\n";
close(MAIL);
}
print header;
my $return=param("return_addr");
if (! defined $return or ! $return) {
print "You must supply an email address<P>";
exit;
}
my $subject=param("subject");
if (! defined $subject or ! $subject) {
print "You must supply an subject<P>";
exit;
}
send_mail('mymail@mydomain.net',
$return,
$subject,
param("body"));
print "Mail sent.";
SCRIPT ENDS HERE
HTML BEGINS HERE
<b><CENTER>Woodbury Golf Course tournament entry form</CENTER></b><BR><BR>
Please complete all fields of the form. Thank you.<br><br>
Full name:<BR>
<INPUT name=name>
<BR>
<BR>
Address:<BR>
<Input name=address>
<BR>
<BR>
City:<BR>
<Input name=city>
<BR>
<BR>
State:<BR>
<Input name=state>
<BR>
<BR>
Zip:<BR>
<Input name=zip>
<BR>
<BR>
Phone:<BR>
<Input name=phone>
<BR>
<BR>
Your e-mail address:<BR>
<INPUT name=return_addr>
<BR>
<BR>
Are you a member?:<BR>
<INPUT type=radio value=yes name=member>Yes
<INPUT type=radio value=no name=member>No
<BR>
<BR>
Subject:<BR>
<INPUT value="Tournament entry" name=subject>
<BR>
<BR>
I wish to register for:<BR>
<INPUT type=radio value=Scratch name=event>Scratch (September 10)
<INPUT type=radio value=Handicap name=event>Handicap (September 17)
<INPUT type=radio value=Both name=event>Both events
<BR>
<BR>
Please enter any additional information (including handicap if known and entering handicap event):<br>
<TEXTAREA name=details rows=10 wrap=hard cols=40></TEXTAREA>
<BR>
<BR>
<INPUT type=submit value=Send Message?> </FORM>