Page 1 of 1

Form to email - add BCC

Posted: Thu Jan 13, 2011 2:33 pm
by trillodigital
Hi,

Please could somebody help. I need my form to send an email to a BCC email address. Here's my current code. It works well, but without the BCC function.

Code: Select all

<?php

// get posted data into local variables
$EmailFrom = "Enquiry";
$EmailTo = "robin@trillodigital.co.uk";
$Subject = "Maria Watt Foundation website enquiry";
$name = Trim(stripslashes($_POST['name'])); 
$email = Trim(stripslashes($_POST['email']));
$telephone = Trim(stripslashes($_POST['telephone'])); 
$comments = Trim(stripslashes($_POST['comments'])); 

// validation
if (strtolower($_POST['code']) != 'mwf') {die('Sorry, you have entered the wrong code. This measure is in place to prevent spam via this website. Please go back and enter the correct code.');}

$validationOK=true;
if (Trim($email)=="") $validationOK=false;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.mariawattfoundation.org/error.html\">";
  exit;
}

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $email;
$Body .= "\n";
$Body .= "Telephone: ";
$Body .= $telephone;
$Body .= "\n";
$Body .= "Comments: ";
$Body .= $comments;
$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=http://www.mariawattfoundation.org/thankyou.html\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.mariawattfoundation.org/error.html\">";
}
?>
Thanks in advance!

Re: Form to email - add BCC

Posted: Thu Jan 13, 2011 2:37 pm
by superdezign
It's part of the e-mail headers. You have the "From:" header already. I believe the header for blinded carbon copy is "Bcc:". Be careful, though. Many mail applications will automatically flag messages that have "Bcc:" headers as spam.