By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,253 Members | 1,333 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,253 IT Pros & Developers. It's quick & easy.

CGI application misbehaved by not returning a complete set of HTTP headers

P: 37
Hi
I am trying to setup a form that automatically sends the form values
via email to a specific address.
I have uploaded the script, which when I run loads a page with the following
error message:

CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers.


According to the tutorial I am using the only thing I needed to change was the
$recipient's email address to my own, which I have done.

my $recipient = 'my@name465.fsnet.co.uk';

I also changed this part to my own email address

print MAIL "To: my\@name465.fsnet.co.uk\n";

Is there perhaps something missing from one of the other headers?


#!/usr/bin/perl -wT
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;

print header;
print start_html("Results");

# Set the PATH environment variable to the same path
# # where sendmail is located:
#
$ENV{PATH} = "/usr/sbin";

# open the pipe to sendmail
open (MAIL, "|/usr/sbin/sendmail -oi -t ") or &dienice("Can't fork for sendmail: $!\n");

# change this to your own e-mail address
my $recipient = 'my@name465.fsnet.co.uk';

# Start printing the mail headers
# You must specify who it's to, or it won't be delivered:

print MAIL "To: my\@name465.fsnet.co.uk\n";

# From should probably be the webserver, although you could set it
# to the visitor's email address too.

print MAIL "From: nobody\@nobody.com\n";

# print out a subject line so you know it's from your form cgi.

print MAIL "Subject: Form Data\n\n";

# Now print the body of your mail message.

foreach my $p (param()) {
print MAIL "$p = ", param($p), "\n";
}

# Be sure to close the MAIL input stream so that the message
# actually gets mailed.

close(MAIL);

# Now print a thank-you page

print <<EndHTML;
<h2>Thank You</h2>
<p>Thank you for writing!</p>
<p>Return to our <a href="index.html">home page</a></p>
EndHTML

print end_html;

# The dienice subroutine handles errors.

sub dienice {
my ($errmsg) = @_;
print "<h2>Error</h2>\n";
print "<p>$errmsg</p>\n";
print end_html;
exit;
}
Mar 25 '08 #1
Share this Question
Share on Google+
1 Reply


numberwhun
Expert Mod 2.5K+
P: 3,503
Hi
I am trying to setup a form that automatically sends the form values
via email to a specific address.
I have uploaded the script, which when I run loads a page with the following
error message:

CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers.


According to the tutorial I am using the only thing I needed to change was the
$recipient's email address to my own, which I have done.

my $recipient = 'my@name465.fsnet.co.uk';

I also changed this part to my own email address

print MAIL "To: my\@name465.fsnet.co.uk\n";

Is there perhaps something missing from one of the other headers?


#!/usr/bin/perl -wT
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;

print header;
print start_html("Results");

# Set the PATH environment variable to the same path
# # where sendmail is located:
#
$ENV{PATH} = "/usr/sbin";

# open the pipe to sendmail
open (MAIL, "|/usr/sbin/sendmail -oi -t ") or &dienice("Can't fork for sendmail: $!\n");

# change this to your own e-mail address
my $recipient = 'my@name465.fsnet.co.uk';

# Start printing the mail headers
# You must specify who it's to, or it won't be delivered:

print MAIL "To: my\@name465.fsnet.co.uk\n";

# From should probably be the webserver, although you could set it
# to the visitor's email address too.

print MAIL "From: nobody\@nobody.com\n";

# print out a subject line so you know it's from your form cgi.

print MAIL "Subject: Form Data\n\n";

# Now print the body of your mail message.

foreach my $p (param()) {
print MAIL "$p = ", param($p), "\n";
}

# Be sure to close the MAIL input stream so that the message
# actually gets mailed.

close(MAIL);

# Now print a thank-you page

print <<EndHTML;
<h2>Thank You</h2>
<p>Thank you for writing!</p>
<p>Return to our <a href="index.html">home page</a></p>
EndHTML

print end_html;

# The dienice subroutine handles errors.

sub dienice {
my ($errmsg) = @_;
print "<h2>Error</h2>\n";
print "<p>$errmsg</p>\n";
print end_html;
exit;
}

Sorry, I don't know the answer but hopefully one of our experts will be able to assist you.

My appologies for the delay in getting an answer to your question.

Regards,

Jeff
Apr 17 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.