为什么我的自动响应代码不起作用


Why is my auto respond code not working?

我有一个联系人表单,它会向我发送已提交的信息。问题是它没有向客户发送电子邮件来确认提交。下面列出了完整的代码。如果有人能告诉我我缺少了什么,或者我应该改变什么,我将不胜感激。

<?php
if(isset($_POST['Email_Address'])) {
include 'freecontactformsettings.php';
function died($error) {
    echo "Sorry, but there were error(s) found with the form you submitted. ";
    echo "These errors appear below.<br /><br />";
    echo $error."<br /><br />";
    echo "Please go back and fix these errors.<br /><br />";
    die();
}
if(!isset($_POST['Full_Name']) ||
    !isset($_POST['Email_Address']) ||
    !isset($_POST['Telephone_Number']) ||
    !isset($_POST['Your_Message']) || 
    !isset($_POST['AntiSpam'])      
    ) {
    died('Sorry, there appears to be a problem with your form submission.');        
}
$full_name = $_POST['Full_Name']; // required
$email_from = $_POST['Email_Address']; // required
$telephone = $_POST['Telephone_Number']; // not required
$comments = $_POST['Your_Message']; // required
$antispam = $_POST['AntiSpam']; // required
if (isset($_POST['newsletter'])) {
$newsletter = "yes";
} else {
$newsletter = "no";
}
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+'.[A-Za-z]{2,4}$/';
if(preg_match($email_exp,$email_from)==0) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
if(strlen($full_name) < 2) {
$error_message .= 'Your Name does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if($antispam <> $antispam_answer) {
$error_message .= 'The Anti-Spam answer you entered is not correct.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.'r'n";
function clean_string($string) {
  $bad = array("content-type","bcc:","to:","cc:");
  return str_replace($bad,"",$string);
}
$email_message .= "Full Name: ".clean_string($full_name)."'r'n";
$email_message .= "Email: ".clean_string($email_from)."'r'n";
$email_message .= "Telephone: ".clean_string($telephone)."'r'n";
$email_message .= "Message: ".clean_string($comments)."'r'n";
$email_message .= "Newsletter: ".clean_string($newsletter)."'r'n";
$headers = 'From: '.$email_from."'r'n".
'Reply-To: '.$email_from."'r'n" .
'X-Mailer: PHP/' . phpversion();
mail($email_to, $email_subject, $email_message, $headers);
header("Location: $thankyou");
?>
<script>location.replace('<?php echo $thankyou;?>')</script>

if ($email->send()){ 
$autoemail = new PHPMailer(); 
$autoemail->From = "noreply@altfuels.com"; 
$autoemail->FromName = "Alt Fuels"; 
$autoemail->AddAddress($email_from->Email Address, $full_name->Full Name); 
$autoemail->Subject = "Autorepsonse: We received your submission"; 
$autoemail->Body = "We received your submission. We will contact you soon ...";
$autoemail->Send(); 
}  
<?php
}
die();
?>

(*注意:我更改了一些时事通讯代码,在电子邮件中打印了一个"否"的答案。)

看起来您引用的是未定义的$thankyou,除非它是在尚未列出的freecontactformsettings.php中定义的。