Web Hosting Talk







View Full Version : Mail form


syanet
03-29-2001, 05:06 PM
I have a form mail script that has worked great on every server I've used it on, but I cannot get it to work on a RaQ4i. When I submit, I get the dreaded "The server encountered an internal error or misconfiguration and was unable to complete your request" error. It is uploaded correctly and has been CHMODed to 777 just to be sure. I posted the entire script below for anyone to take a look at. Any idea's are welcome because I'm stumped.

[Edited by syanet on 03-31-2001 at 12:31 AM]

Dim8
03-29-2001, 07:56 PM
You need to tell it where the mail program is. $mailprogram doesn't detect the mail server. At the top of the script it should say $mailprogram = /usr/sbin/sendmail or something like that. Did you know if you log into Telnet (or SSH) cd to the directory where the script is and type perl -c scriptname.cgi it will tell you what the error is and even how to fix it? I might be wrong about the mail part. I'm not too advance when it comes to Perl.

syanet
03-29-2001, 08:45 PM
Me neither, that's the problem :(. I comment out the above line, and it works like a charm taking me to the thank you page. I above line is set to "/usr/sbin/sendmail";. I don't know why this script works on every server, except my RaQ.

syanet
03-30-2001, 01:14 AM
Here's the whole script if anyone would care to take a look:

#!/usr/bin/perl

$mailprogram = "/usr/sbin/sendmail";

@required = ('Name','E-Mail','Domain', 'Login', 'Password','Select','Problem');

$youremail = "support\@syanet.com";

$counter = 'counter.txt';

# Put the posted data into variables

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}

# Check for all required fields

foreach $check(@required) {
unless ($FORM{$check}) {
$url = 'http://www.syanet.com/errortwo.shtml';
print "Location: $url\nURI: $url\n\n" ;
}
}

# Check the senders email

if ($FORM{'E-Mail'}) {
unless ($FORM{'E-Mail'} =~ /\w+@\w+.\w+/) {
$url = 'http://www.syanet.com/errortwo.shtml';
print "Location: $url\nURI: $url\n\n" ;
}
}

open(NUMBER,"$counter") || die $!;
$num = <NUMBER>;
close(NUMBER);

$num++;

open(NUMBER,">$counter") || die $!;
print NUMBER $num;
close(NUMBER);


open (MAIL,"|$mailprogram");
print MAIL "To: $youremail\n";
print MAIL "From: $FORM{'E-Mail'}\n";
print MAIL "Subject: Support Request $num\n\n";
print MAIL "Hello. The following information has been submitted:\n\n";
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
unless ($name eq "response" || $name eq "E-Mail" || $name eq "subject") {
print MAIL "$name: $value\n";
}
}
close MAIL;

if ($FORM{'response'} && $FORM{'E-Mail'}) {
open (RESPONSE, $FORM{'response'});
@response = <RESPONSE>;
close(RESPONSE);
open (MAIL,"|$mailprogram");
print MAIL "To: $FORM{'E-Mail'}\n";
print MAIL "From: $youremail\n";
print MAIL "Subject: Support Request $num\n\n";
foreach $line (@response) {
print MAIL "$line";
}
}

$url = 'http://www.syanet.com/thanks.shtml';
print "Location: $url\nURI: $url\n\n" ;

syanet
03-31-2001, 01:33 AM
Dim8... I ran the Perl -c and it says syntax is "OK". Any other suggestions? The error log reports the following:

"malformed header from script. Bad header=Recipient names must be specif: /usr/cgiwrap/cgiwrap".

SI-Chris
03-31-2001, 01:48 AM
I think you need a -t at the end of your sendmail location... as in:
$mailprogram = "/usr/sbin/sendmail -t";

syanet
03-31-2001, 02:12 AM
Originally posted by IntelligentHosting.com
I think you need a -t at the end of your sendmail location... as in:
$mailprogram = "/usr/sbin/sendmail -t";

That's half of it anyway. I get redirected and the counter works, but no e-mail is sent. Any idea's?

syanet
03-31-2001, 08:18 PM
Any other idea's? I've been working on this for 3 days now and still can't figure out why it's not sending the mail.

syanet
04-01-2001, 03:22 AM
Made some more progress. The mail isn't being sent because the script never actually completes itself. I get redirected to an error page (errortwo.shtml) rather than the thank you page.

This is ironic because when running the script through the http://sitename1/cgiwrapDir/cgiwrapd/ method the output reads as follows:

Location: http://216.40.196.41/thanks.htm
URI: http://216.40.196.41/thanks.htm

The first thing I did was changed the @required line to require nothing, but I still receive the error. Any theories why not?

Also, when running the script in Telnet through perl -w, I get "use of uninitalized value on line 13" - read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});. No idea why.

Finally perl -c says syntax is fine.

Any help would be apperciated.

[Edited by syanet on 04-01-2001 at 03:30 AM]

syanet
04-01-2001, 01:35 PM
Good news and bad news. I got to see the thank you page for the first time in a week, but no e-mail is being sent out, including the auto response. Any idea's why not?

[Edited by syanet on 04-01-2001 at 01:42 PM]

syanet
04-01-2001, 01:57 PM
Anyone else have RoadRunner? I think thats the root of my problem. My Outlook program has been corrupted for a few days, so I've been using an online POP3 checker lately. Whenever I receive an e-mail on it it lists my address as name@roadrunner.neo.rr.com. Now the "roadrunner" is usually not in my address. So I set the script to to use that complete address as my e-mail and as the return address. And what a surprise, I got the submission and an autoresponse. Damn RR...