I've fried my brain dealing with my new web host - after arguing with them for three weeks telling them SOMETHING was wrong on their end with my cgi (and having them keep saying "no there isn't" and me roasting my brain trying to figure out what i had done wrong), they finally fixed it, and at least 1/2 my scripts run. But some of them (like this one) will not - and the exact same script works on my other web sites (I just change the location of perl, sendmail, etc). I am getting the error 500 "Premature end of script header". I can see nothing wrong with this script - can some take a quick peek for me please?
Thanks
#!/usr/bin/perl5 -w
use strict;
use CGI qwall);
use CGI::Carp qw(fatalsToBrowser);
$|=1;
# use Fcntl qwflock);
sub send_mail {
my($to, $from, $subject, @detail, @iknow, @jbefore, @comments)=@_;
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 "User information\n\n";
my $name = param("name"
print MAIL "Contact name: $name\n";
my $email=param("return_addr"
print MAIL "Email address: $email\n\n";
print MAIL "Problem report\n\n";
print MAIL "Problem is with software or hardware?\n";
my $event = param("event"
print MAIL "$event\n\n";
print MAIL "User thinks problem might be\n";
my $problem = param("problem"
print MAIL "$problem\n\n";
print MAIL "The problem started\n";
my $start = param("start"
print MAIL "$start\n\n";
print MAIL "Problem details\n\n";
foreach (@detail) {
print MAIL "$_\n";
}
print MAIL "\n";
print MAIL "User thinks problem may have been caused by\n\n";
foreach (@iknow) {
print MAIL "$_\n";
}
print MAIL "\n";
print MAIL "Was anything installed/changed right before problem started?\n\n";
foreach (@jbefore) {
print MAIL "$_\n";
}
print MAIL "\n";
print MAIL "Additional comments and information\n\n";
foreach (@comments) {
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('me@myweb.com',
$return,
$subject,
param("body");
my $priority = param("priority"
if ($priority=="High" {
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 a subject<P>";
exit;
}
send_mail('me@myweb.net',
$return,
$subject,
param("body");
}
print "Mail sent.";
Thanks
#!/usr/bin/perl5 -w
use strict;
use CGI qwall);
use CGI::Carp qw(fatalsToBrowser);
$|=1;
# use Fcntl qwflock);
sub send_mail {
my($to, $from, $subject, @detail, @iknow, @jbefore, @comments)=@_;
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 "User information\n\n";
my $name = param("name"
print MAIL "Contact name: $name\n";
my $email=param("return_addr"
print MAIL "Email address: $email\n\n";
print MAIL "Problem report\n\n";
print MAIL "Problem is with software or hardware?\n";
my $event = param("event"
print MAIL "$event\n\n";
print MAIL "User thinks problem might be\n";
my $problem = param("problem"
print MAIL "$problem\n\n";
print MAIL "The problem started\n";
my $start = param("start"
print MAIL "$start\n\n";
print MAIL "Problem details\n\n";
foreach (@detail) {
print MAIL "$_\n";
}
print MAIL "\n";
print MAIL "User thinks problem may have been caused by\n\n";
foreach (@iknow) {
print MAIL "$_\n";
}
print MAIL "\n";
print MAIL "Was anything installed/changed right before problem started?\n\n";
foreach (@jbefore) {
print MAIL "$_\n";
}
print MAIL "\n";
print MAIL "Additional comments and information\n\n";
foreach (@comments) {
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('me@myweb.com',
$return,
$subject,
param("body");
my $priority = param("priority"
if ($priority=="High" {
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 a subject<P>";
exit;
}
send_mail('me@myweb.net',
$return,
$subject,
param("body");
}
print "Mail sent.";