联系表单不向管理员发送访客电子邮件

时间:2016-07-17 11:07:56

标签: php

我有这个联系表单,不会发送电子邮件给我,让我知道有人访问了我的网站,我错了。谢谢。这是有问题的测试website



<?php
function test_input($data) {
   $data = trim($data);
   $data = stripslashes($data);
   $data = htmlspecialchars($data);
   return $data;
}

$field_email = test_input($_POST['email']);
$field_name = test_input($_POST['name']);
$field_residence = test_input($_POST['residence']);
$field_profession = test_input($_POST['profession']);
$field_club = test_input($_POST['fave_club']);
$field_message = test_input($_POST['message']);


$mail_to = 'idwapro2@gmail.com';
$subject = 'Message from vidz.dundaah visitor '.$field_name;

$body_message = 'E-mail: '."\n".$field_email."\n\n";
$body_message .= 'Name: '."\n".$field_name."\n\n";
$body_message .= 'Residence: '."\n".$field_residence."\n\n";
$body_message .= 'Profession: '."\n".$field_profession."\n\n";
$body_message .= 'Fave_club: '."\n".$field_club."\n\n";
$body_message .= 'Message: '."\n".$field_message;

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers = 'From: '.$field_name."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";

$mail_status = mail($mail_to, $subject, $body_message, $headers);

header("Location:../contact.html"); 

?>
&#13;
&#13;
&#13;

0 个答案:

没有答案