Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email BCC

Status
Not open for further replies.

mcode12

Programmer
Aug 8, 2007
25
GB
How would I do a BCC for the code below?

<?php

$Name = $_REQUEST['Name'] ;
$Email = $_REQUEST['Email'] ;
$Query = $_REQUEST['Query'] ;

$flag="OK"; // This is the flag and we set it to OK
$msg=""; // Initializing the message to hold the error messages

if(strlen($Name) < 5){ // checking the length of the entered userid and it must be more than 5 character in length
$msg=$msg."<strong>Please make sure you enter your full name</strong><br />";
$flag="NOTOK"; //setting the flag to error flag.
}
if(stristr($Name,"Your name")){ //
//if($Name="Your name"){ //
$msg=$msg."<strong>Please make sure your name is not the default in the text field</strong><br />";
$flag="NOTOK"; //setting the flag to error flag.
}

if(strlen($Email) < 1){ //
$msg=$msg."<strong>Please enter an email</strong><br />";
$flag="NOTOK"; //setting the flag to error flag.
}

if (!stristr($Email,"@") OR !stristr($Email,".")) {
$msg=$msg."<strong>Please make sure you enter a valid email</strong><br />";
$flag= "NOTOK";} //setting the flag to error flag.

if(strlen($Query) < 10){ //
$msg=$msg."<strong>Please enter a valid query</strong><br />";
$flag="NOTOK"; //setting the flag to error flag.
}

//if($Query="Enter your message here to contact us"){ //
if(stristr($Query,"Enter your message here to contact us")){ //
$msg=$msg."<strong>Please make sure your comments are not the default comments in the text field</strong><br />";
$flag="NOTOK"; //setting the flag to error flag.
}



if($flag <>"OK"){
echo "<p>Please click on the browser back button and make the following changes;</p><p>$msg </p>";
}else{


$my_email = "myemail@emailaddress.com";
if ($_SERVER['REQUEST_METHOD'] != "POST"){exit;}

$disallowed_name = array(':',';',"'",'"','=','(',')','{','}','@');

foreach($disallowed_name as $value)
{

if(stristr($_POST[Name],$value)){header("location: $_SERVER[HTTP_REFERER]");exit;}

}

$disallowed_email = array(':',';',"'",'"','=','(',')','{','}');

foreach($disallowed_email as $value)
{

if(stristr($_POST,$value)){header("location: $_SERVER[HTTP_REFERER]");exit;}

}

$message = "";

while(list($key,$value) = each($_POST)){if(!(empty($value))){$set=1;}$message = $message . "$key: $value\n\n";} if($set!==1){header("location: $_SERVER[HTTP_REFERER]");exit;}

$message = $message . "";
$message = stripslashes($message);

$subject = "Enquiry";
$headers = "From: " . $_POST['Email'] . "\n" . "Return-Path: " . $_POST['Email'] . "\n" . "Reply-To: " . $_POST['Email'] . "\n";
?>
<h4>Thank you <?php print stripslashes($_POST['Name']); ?>.</h4>
<p>Your query has been sent and will be replied to if necessary.</p>
<?
mail($my_email,$subject,$message,$headers);
}
?>

thanks.

 
Have you looked at the manual?

See Example #4 on this page:
-
Clive
Runner_1Revised.gif

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer." (Paul Ehrlich)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Be aware that some hosts (one I use for one) prevent the use of sending BCC via PHP as an anti-spam measure.

--
Tek-Tips Forums is Member Supported. Click Here to donate

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.


 
for anything more than trivial mailing requirements (such as the occasional sending of short log information) i would always use phpmailer.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top