如何将BCC添加到我的联系表单中

时间:2014-05-27 13:01:15

标签: php forms email contact-form

如何将BCC添加到我的联系表单中?我尝试了几种不同的方法,但我不确定为什么它不起作用。我知道我需要添加带有密件抄送的@header但到目前为止没有运气。

这是我的PHP代码;它最初来自CSStricks comment

<?php

$EmailFrom = "myemails@emails.com";
$EmailTo = "myemails@emails.com";
$Subject = "Popes Enterprises Contact Form";
$Name = Trim(stripslashes($_POST['Name'])); 
$Tel = Trim(stripslashes($_POST['Tel'])); 
$Email = Trim(stripslashes($_POST['Email'])); 
$Message = Trim(stripslashes($_POST['Message'])); 

// validation
$validationOK=true;
if (!$validationOK) {
 print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
 exit;
}

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "City: ";
$Body .= $City;
$Body .= "\n";
$Body .= "Tel: ";
$Body .= $Tel;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";

// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page 
 if ($success){
 print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";
}
else{
 print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>

1 个答案:

答案 0 :(得分:0)

我不认为你试过谷歌搜索你的问题,但这里有一个链接,它将解释你如何使用PHP邮件功能http://www.htmlite.com/php029.php