View Full Version : No emails being received when forms submitted

10-14-2009, 09:04 PM

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.

use CGI::Carp qw(fatalsToBrowser);


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


sub thank_you {

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

print <<EndStart;

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



Thanks in advance