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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Max58kl
    New Member
    • Nov 2007
    • 37

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

    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.fsn et.co.uk';

    I also changed this part to my own email address

    print MAIL "To: my\@name465.fsn et.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(warningsToBr owser fatalsToBrowser );
    use strict;

    print header;
    print start_html("Res ults");

    # 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("Ca n't fork for sendmail: $!\n");

    # change this to your own e-mail address
    my $recipient = 'my@name465.fsn et.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.fsn et.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.htm l">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;
    }
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    Originally posted by Max58kl
    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.fsn et.co.uk';

    I also changed this part to my own email address

    print MAIL "To: my\@name465.fsn et.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(warningsToBr owser fatalsToBrowser );
    use strict;

    print header;
    print start_html("Res ults");

    # 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("Ca n't fork for sendmail: $!\n");

    # change this to your own e-mail address
    my $recipient = 'my@name465.fsn et.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.fsn et.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.htm l">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

    Comment

    Working...