in reply to Re: Re: Re: Premature end of script headers
in thread Premature end of script headers

I tried to make my own code up using the second response and taking the sendmail out of the first lot of code you gave me but I am still having no luck. Could you just have a look at my revised code and give me some thoughts and feedback. I tried the original script but I couldn't even get that working. Thanks heaps for your time. I thought no one would help but you have been more than helpful.
#!/usr/bin/perl -wT use CGI; use CGI::Carp qw(fatalsToBrowser); CGI::ReadParse(); print MAIL "$in{'Title'}\n"; print MAIL "$in{'Name'}\n"; print MAIL "$in{'Position'}\n"; print MAIL "$in{'School'}\n"; print MAIL "$in{'Address'}\n"; print MAIL "$in{'Suburb'}\n"; print MAIL "$in{'State'}\n"; print MAIL "$in{'PCode'}\n"; print MAIL "$in{'Email'}\n"; print MAIL "$in{'Telephone'}\n"; print MAIL "$in{'Fax'}\n"; print MAIL "$in{'PR01'}\n"; print MAIL "$in{'PR02'}\n"; print MAIL "$in{'PR03'}\n"; print MAIL "$in{'PR04'}\n"; print MAIL "$in{'PR05'}\n"; print MAIL "$in{'PR06'}\n"; print MAIL "$in{'PR07'}\n"; print MAIL "$in{'PR08'}\n"; print MAIL "$in{'Att1'}\n"; print MAIL "$in{'Att2'}\n"; print MAIL "$in{'Att3'}\n"; print MAIL "$in{'Att4'}\n"; print MAIL "$in{'Att5'}\n"; print MAIL "$in{'Att6'}\n"; print MAIL "$in{'Att7'}\n"; print MAIL "$in{'Att8'}\n"; print MAIL "$in{'Att9'}\n"; print MAIL "$in{'Comments'}\n"; my $mailer = new Mail::Mailer ( "smtp" ); $mailer->open( { To => 'dawson.nicholas.a@edumail.vic.gov.au', From => $in{'Email'}, Subject => 'Travancore School Professional Development' } ); print $mailer; $mailer->close; print $query->redirect('http://www.travancoresch.vic.edu.au/developmen +t/reply02.html');

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Premature end of script headers
by Limbic~Region (Chancellor) on Aug 05, 2003 at 00:10 UTC
    Nickd_69,
    Ok - you have forgetten to use Mail::Mailer which might just be a typo on your part. I would suggest reading the docs - it can use Sendmail if you want by replacing 'smtp' with 'sendmail'.

    Additionally - you are printing to the MAIL filehandle, but haven't opened it anywhere. You don't want to do that. Move the my $mailer = stuff before any of the print statements and then change all the MAIL lines to $mailer.

    You also didn't create the CGI object used to redirect the page later.

    You really want to look into hash slices. It could make your life a lot easier. The problem is that unless you have done form validation using JavaScript - you might be attempting to print an uninitalized variable. See my update to your code below:

    #!/usr/bin/perl -wT use CGI; use CGI::Carp qw(fatalsToBrowser); use Mail::Mailer; CGI::ReadParse(); my $query = CGI->new(); my $mailer = new Mail::Mailer ( "smtp" ); $mailer->open( { To => 'dawson.nicholas.a@edumail.vic.gov.au', From => $in{'Email'}, Subject => 'Travancore School Professional Development' } ); print $mailer "$in{'Title'}\n"; print $mailer "$in{'Name'}\n"; print $mailer "$in{'Position'}\n"; $mailer->close; print $query->redirect('http://www.travancoresch.vic.edu.au/developmen +t/reply02.html');
    That should move you along I think, still don't have a web server to test it on though. What were the errors you got with my code anyway?

    Cheers - L~R