Ok, I have tried that but it dosen't work. It will send the form data to our e-mail, but its not generating the autoreply.
Any ideas on why its not doing it ??
Here is the code I have got:
#!/usr/local/bin/perl -w
#--------------------------------------------------------------------------------
#--------------------------------------------------------------------------------
# CGI SCRIPT FOR PROCESSING THE E-MAIL FORM ON OUR WEBSITE
#--------------------------------------------------------------------------------
#--------------------------------------------------------------------------------
#Location of sendmail on server
$MailProgram = '/usr/sbin/sendmail -t';
#Email address to use for sending results
$OurEmail = 'ourmail@oursite.co.uk';
sub ErrorHTML {
#Error handler
my $eh = join '<li>',@_;
print "Content-type: text/html\n\n";
print qq~
<html>
<head>
<title>Notice : Error</title>
</head>
<body>
<h4>Notice:</h4><ul><li>$eh</ul>
</body>
</html>
~;
exit;
}
#-------------------------------------------------------------------------------------
#STARTS PROCESSING THE FORM DATA HERE
#-------------------------------------------------------------------------------------
sub Parse {
#Parse form submission sent by user
my $buffer;
ErrorHTML('Form must use method "POST"') unless ($ENV{REQUEST_METHOD} eq 'POST');
read(STDIN,$buffer,$ENV{CONTENT_LENGTH});
my @data = split(/&/,$buffer);
for(@data) {
$_ =~ tr/+/ /;
my ($n,$v) = split(/=/,$_);
$n =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
$v =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
$v =~ s/\<(.*?)embed/\<$1\_e_m_b_e_d_\(mailer_robot_edited\)/sig;
$v =~ s/\<(.*?)object/\<$1\_o_b_j_e_c_t_\(mailer_robot_edited\)/sig;
$v =~ s/\<(.*?)script/\<$1\_s_c_r_i_p_t_\(mailer_robot_edited\)/sig;
$v =~ s/\<(.*?)applet/\<$1\_a_p_p_l_e_t_\(mailer_robot_edited\)/sig;
$fields{$n} = $v;
}
}
#-------INITIATES CHECK AUTHORIZED AND PARSE FUNCTION-------------------------------
Parse;
#-------STARTS TO WRITE THE EMAIL----------------------------------------------------
$subject = 'Website request for brochure';
open MAIL,"|$MailProgram";
print MAIL <<TO_END;
To: $OurEmail
From: $fields{EMail} <"$fields{FirstName}""$fields{LastName}">
Subject: $subject
Content-Type: text/plain; charset="us-ascii"
------------------------------------------------------------
Title: $fields{title}
First Name: $fields{FirstName}
Last Name: $fields{LastName}
Address: $fields{Address}
Town: $fields{Town}
County: $fields{County}
Postcode: $fields{Postcode}
Number: $fields{Telephone}
E-mail: $fields{EMail}
------------------------------------------------------------
------------------------------------------------------------
IP: $ENV{REMOTE_ADDR}
Form: $ENV{HTTP_REFERER}
------------------------------------------------------------
------------------------------------------------------------
TO_END
close MAIL;
#--------Autoresponder----------------------------------------------------------
open MAIL,"|$MailProgram";
print MAIL <<TO_END;
To: $fields{EMail}
From: $OurEmail
Subject: Autoresponder
Content-Type: text/plain; charset="us-ascii"
------------------------------------------------------------
The body of the e-mail autoresponder is written here
------------------------------------------------------------
TO_END
close MAIL;
print "Location:
http://www.oursite.co.uk\n\n";