PDA

View Full Version : No emails being received when forms submitted


Jules1777
10-14-2009, 10:04 PM
Hi

Can someone please help!!

I am setting up a survey form form which is uploaded to http://www.mentalhealthstrategies.co.uk/survey.html
The only thing is once it is filled in and submitted, the 'thank you' page is loaded but I am not receiving any email to give me the details.

My CGI script is as below. Can someone please tell me what I have done wrong. I am quite new to scripting and I am not sure what I have done wrong.

#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);

if ($ENV{'REQUEST_METHOD'} eq 'POST') {

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;
}

open (MESSAGE,"| /usr/sbin/sendmail -t");

print MESSAGE "To: julie.mak\@mentalhealthstrategies.co.uk \n";
print MESSAGE "From: " . $FORM{name} . ", reader\n";
print MESSAGE "Subject: Feedback from $FORM{name} \n\n";
print MESSAGE "Organisaion: $FORM{mail} \n\n";
print MESSAGE "Question 1: $FORM{question1} \n\n";
print MESSAGE "Question 2: $FORM{question2} \n\n";
print MESSAGE "Question 3: $FORM{question3} \n\n";
print MESSAGE "Question 4: $FORM{question4} \n\n";
print MESSAGE "Question 5: $FORM{question5} \n\n";
print MESSAGE "Question 6: $FORM{question6} \n\n";
print MESSAGE "Question 7: $FORM{question7} \n\n";
print MESSAGE "Question 8: $FORM{question8} \n\n";
print MESSAGE "Question 9: $FORM{question9} \n\n";
print MESSAGE "Question 10: $FORM{question10} \n\n";
print MESSAGE "Sent by: $FORM{name}\n";

close (MESSAGE);

&thank_you;
}

sub thank_you {

print "Content-type: text/html\n\n";

print <<EndStart;

<html>
<head>
<title>Thank You</title>
</head>
<body bgcolor="#dae7a2" text="#000000">
<h1>Thank You</h1>
<p>Your survey has been received. Thanks for taking the time to answer it.</p>
<hr>
EndStart
print <<EndHTML;
</body>
</html>

EndHTML

exit(0);
}

Thanks in advance
Jules1777
:confused: