Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NMS Formmail premature end of script headers

Status
Not open for further replies.

27dmac

Technical User
Mar 10, 2004
7
0
0
US
I've used this script on lots of other sites, and never got this problem before.

The HTML form calls for posting to mydomain.com/cgi-bin/contactForm.pl with a recipient value of 1.

Here's the top part of the form

Code:
#!/usr/bin/perl 
#
# $Id: FormMail.pl,v 2.22 2003/02/21 13:55:24 nickjc Exp $
#

use strict;
use POSIX qw(locale_h strftime);
use Text::Wrap;              # Er for wrapping :)
use Socket;                  # for the inet_aton()
use CGI qw(:standard);
use vars qw(
  $DEBUGGING $emulate_matts_code $secure
  $allow_empty_ref $max_recipients $mailprog @referers
  @allow_mail_to @recipients %recipient_alias
  @valid_ENV $date_fmt $style $send_confirmation_mail
  $confirmation_text $locale $charset $no_content
  $double_spacing $wrap_text $wrap_style $postmaster
);

# PROGRAM INFORMATION
# -------------------
# FormMail.pl $Revision: 2.22 $
#
# This program is licensed in the same way as Perl
# itself. You are free to choose between the GNU Public
# License <[URL unfurl="true"]http://www.gnu.org/licenses/gpl.html>[/URL]  or
# the Artistic License
# <[URL unfurl="true"]http://www.perl.com/pub/a/language/misc/Artistic.html>[/URL]
#
# For help on configuration or installation see the
# README file or the POD documentation at the end of
# this file.

# USER CONFIGURATION SECTION
# --------------------------
# Modify these to your own settings. You might have to
# contact your system administrator if you do not run
# your own web server. If the purpose of these
# parameters seems unclear, please see the README file.
#
BEGIN
{
  $DEBUGGING         = 0;
  $emulate_matts_code= 0;
  $secure            = 1;
  $allow_empty_ref   = 1;
  $max_recipients    = 5;
  $mailprog          = '/usr/sbin/sendmail';
  $postmaster        = '';
  @referers          = qw(mydomain.com localhost);
  @allow_mail_to     = qw(webmaster@mydomain.com info@mydomain.com 
  						events@mydomain.com register@mydomain.com
  						letters@mydomain.com publicity@mydomain.com
  						research@mydomain.com outreach@mydomain.com localhost);
  @recipients        = ();
  %recipient_alias   = ('1' => 'webmaster@mydomain.com',
  						'2' => 'info@mydomain.com',
  						'3' => 'events@mydomain.com',
  						'4' => 'register@mydomain.com',
  						'5' => 'letters@mydomain.com',
  						'6' => 'publicity@mydomain.com',
  						'7' => 'research@mydomain.com',
  						'8' => 'outreach@mydomain.com);
  @valid_ENV         = qw(REMOTE_HOST REMOTE_ADDR REMOTE_USER HTTP_USER_AGENT);
  $locale            = '';
  $charset           = 'iso-8859-1';
  $date_fmt          = '%A, %B %d, %Y at %H:%M:%Z';
  $style             = 0;
  $no_content        = 0;
  $double_spacing    = 1;
  $wrap_text         = 1;
  $wrap_style        = 1;
  $send_confirmation_mail = 0;
  $confirmation_text = <<'END_OF_CONFIRMATION';
  
From: you@your.com
Subject: form submission

Thank you for your form submission.

END_OF_CONFIRMATION
#
# USER CONFIGURATION << END >>
# ----------------------------
# (no user serviceable parts beyond here)

Anybody that can offer a clue what I've done wrong?

The steps to perl and sendmail are correct for the hosting server.

All help appreciated.

Thanks,
Donna
 
Could be any number of things but I'd start looking at these:

use POSIX qw(locale_h strftime);
use Text::Wrap; # Er for wrapping :)
use Socket; # for the inet_aton()

maybe this hosting server doesn't have these packages installed. Your error logs will be the biggest help.

There's always a better way. The fun is trying to find it!
 
This is from the log - repeats same two lines for each try.

Code:
[Tue Jul 27 16:43:26 2004] [error] [client 00.11.222.22] File does not exist: /home/sussexco/public_html/500.shtml
[Tue Jul 27 16:43:26 2004] [error] [client 00.11.222.22] Premature end of script headers: /home/user/public_html/cgi-bin/contactForm.pl

Any better?

Thanks,
Donna
 
It appears that there may be an ubderlying problem: this file can't be found:
/home/sussexco/public_html/500.shtml

and it may be that one is calling the other. You'll have to do soem more investigative work to eliminate each error.

There's always a better way. The fun is trying to find it!
 
500 is simply the system error page,

That's not going to cure your problem, only find the right page instead of issuing "Internal Server Error"

Prem end script headers is usuall because the Content Type header hasn't been output before writing to the browser, and the webserver interjects - Apache is less forgiving than IIS, because Apache is a real webserver.

I don't think the probelm is with user serviceable parts. The bit you're looking for is
Code:
print "Content-Type: text/html\n\n";

and make sure there's nothing printed before it, or errors trapped, and output to screen.

The quickest way to check this is to
1) Check the syntax of the form - on the command line, preferably on the server perl -c myscript.pl
2) Run the script on the server console again command line -perl myscript.pl


HTH
--Paul


It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
Thansk, Paul. I found it - it was as simple as the missing ' before the ) at the end of the last recipient alias, e.g. '8' => 'outreach@mydomain.com);

Thanks,
Donna
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top