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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form

Status
Not open for further replies.

guest101

Programmer
Aug 10, 2004
8
US
I am beyond frustrated. I tried to design my 2nd mail form in perl since my first one was so messed up. This one is a millions times more basic than my last one yet NO ONE in chatrooms know what is wrong.

I do not get a real error, just a normal ISE (internal server error) or a misconfiguration. It is setup in my cgi bin and chmoded to 755. It is linked properly from my form. Sendmail is correct too.

Some people say it works for them, other people say it does. I have NO clue why this is.

What is weird, I still get emails sometimes when the form is used even though it gives an error message. Sometimes it doesn't email me, just gives an error. What is real wierd is if the person types in something like 'aaa' in the email field it shows aaa@ in the FROM when I get the email. Inoverse is my webhost and NO WHERE in the script below do I tell it to have anything to do with them.

Can anyone see the problem with the script below?

Thanks millions!

Guest101



#!/usr/bin/perl -w
print "Content-type: text/html\n\n";

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

######################################################################
##########################VARIABLES/MUST EDIT########################
# Change to your full name
$webmastername = 'Name Of Webmaster';

# Change with your email account
$adminemail = 'sulfericacid@qwest. net';

# Change to correct path of sendmail
#$sendmail = '/usr/sbin/sendmail';

# Change to email subject for email to visitor. Ie. "Thanks for your submission"
$subject = 'Enter Subject Here';

# Change to email subject for email to you. Ie. "Someone used your form"
$subject2 = 'Enter Subject Here';

# Change to message you want emailed to visitor. Ie. "Your submission was recieved. Site features, etc."
$message = 'Personalized message';

# Homepage url, do not link to form, use your index. Ie. " submission.com"
$homepage = 'url of homepage';

# Change to enclosure. Ie. "Sincerly yours"
$thanks = 'Personalized thank you or please come again';

# Change to title of thank you page. Ie. "Form processed and received"
$title = 'Title of End page';

######################################################################
#######################EMAIL TO VISITOR/DON'T EDIT######################
#open(MAIL,"|$sendmail -t");
print MAIL "To: ($FORM{'recipientemail'})\n";
print MAIL "From: $adminemail\n";
print MAIL "Subject: $subject\n";
print MAIL "($FORM{'visitorname'})\n";
print MAIL "$message\n";
print MAIL "$thanks\n";
print MAIL "$webmastername\n";
print MAIL "mailto:$adminemail\n";
print MAIL "$homepage\n";
close(MAIL);

######################################################################
#######################EMAIL TO ADMIN/DON'T EDIT#######################
#open(MAIL,"|$sendmail -t");
print MAIL "To: $adminemail\n";
print MAIL "From: ($FORM{'recipientemail'})\n";
print MAIL "Subject: $subject2\n";
print MAIL "($FORM{'visitorname'})\n";
print MAIL "($FORM{'recipientemail'})";
print MAIL "($FORM{'weburl'})";
print MAIL "$(FORM{'message'})";
close(MAIL);

######################################################################
########################PRINT THANK YOU/MUST EDIT#####################
print &quot;<HTML>\n&quot;;
print &quot;<HEAD>\n&quot;;
print &quot;<TITLE>$title</TITLE>\n&quot;;
print &quot;</HEAD>\n&quot;;
print &quot;<BODY>\n&quot;;
print &quot;<p>Thank you for your message. If you are waiting for a response, please allow upto 24 hours.</p>\n&quot;;
print &quot;</BODY>/n&quot;;
print &quot;</HTML>/n&quot;;
 
First things first.....

The strange email addresses you are getting may be from the server making an assumption that if they are only putting in something like aaa, then they must be at that is why you are getting the aaa@ I have no idea why it would do this, but have seen some strange things from servers....... I would add a regex to check the syntax of the address they entered to make sure that the user put in a complete email address.....

Next, I don't see any errors in the script, but you may want to try this to see how it works for you. This is off the top of my head so there may be some syntax errors or such in here, but it should get you started....

open(MAIL, &quot;| /usr/sbin/sendmail -t&quot;) || Die (&quot;Error: $!&quot;);
$r = select(MAIL); $|=1;

print &quot;To: $adminemail\n&quot;;
print &quot;From: ($FORM{'recipientemail'})\n&quot;;
print &quot;Subject: $subject2\n&quot;;
print &quot;($FORM{'visitorname'})\n&quot;;
print &quot;($FORM{'recipientemail'})&quot;;
print &quot;($FORM{'weburl'})&quot;;
print &quot;$(FORM{'message'})&quot;;

close(MAIL);

select($r);

Let me know how it goes,
Jim
 
On the script I gave you above, I commented out the parsing. Some people in chatrooms think it is the form parsing that is wrong. Could that be a possibility?

Also another question. My url is set at sulfericacid@qwest.net when some other scripts say you need to have it sulfericacid/@qwest.net . Would this make any difference in this script?

Thanks.

Aaron
 
That could definitely cause a problem! You need to escape the @ any time you use it in a variable value (unless you put the value in apostrophes instead of quotes). I'm sure you meant \@ and not /@ too, of course. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top