Page 1 of 1

rookie MAIL() question

Posted: Mon Nov 30, 2009 2:04 pm
by bhamberg
Thanks in advance for your help, new to PHP scripting. Script below works OK except for the BCC address and the validation. The validation I can live without but I need the BCC header. What am I missing?
____________________________________________________________

Code: Select all

<?php   
 
$EmailFrom = "RegInfo@reginfo.com";  
$EmailTo = "Regemailto@regemialto.com";
$EmailBCC = "BCemail@BCCemail.com.com";
$Subject = "2010 Registration";
$First = Trim(stripslashes($_POST['First']));
$Last = Trim(stripslashes($_POST['Last']));
$Email = Trim(stripslashes($_POST['Email']));
$Cell = Trim(stripslashes($_POST['Cell']));
$Phone2 = Trim(stripslashes($_POST['Work']));
$Office = Trim(stripslashes($_POST['Office']));
$List = Trim(stripslashes($_POST['List']));
 
// validation
 
/*$validationOK=true; 
 
if (Trim($EmailFrom)=="") $validationOK=false;
if (Trim($EmailTo)=="") $validationOK=false;
if (Trim($First)=="") $validationOK=false;
if (Trim($Last)=="") $validationOK=false;
 
//if (Trim($Cell)=="") $validationOK=false;
 
if (!$validationOK) {   print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";   exit; }
 
*/  
 
// prepare email body text 
 
$Body = ""; 
$Body .= "First: "; $Body .= $First;
$Body .= "\n";
$Body .= "Last: "; $Body .= $Last;
$Body .= "\n";
$Body .= "Email: "; $Body .= $Email;
$Body .= "\n";
$Body .= "Phone: "; $Body .= $Cell;
$Body .= "\n";
$Body .= "Phone2: "; $Body .= $Phone2;
$Body .= "\n";
$Body .= "Office: "; $Body .= $Office;
$Body .= "\n";
$Body .= "Put on list?: "; $Body .= $List;
$Body .= "\n";
 
// send email
 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>\n" ."BCC: <$EmailBCC>\n");
 
// redirect to success page
 
if ($success){   print "<meta http-equiv=\"refresh\" content=\"0;URL=aosintro.htm\">"; } else{   alert('There was an error, please try again.'); }
 
?>

Re: rookie MAIL() question

Posted: Mon Nov 30, 2009 2:27 pm
by Christopher
Check the docs and examples: http://us2.php.net/manual/en/function.mail.php .

I think you need "\r\n" between extra headers.