I am trying to send Bcc mail .My mail function is working for single mail but when I am trying for bcc mail then I nothing happen .help me for possible solution .
<?php
if(isset($_POST['submit'])){
//$to = "example@com"; // this is your Email address
$to = "example@com";
$from = $_POST['email']; // this is the sender's Email address
$first_name = $_POST['name'];
$last_number = $_POST['number'];
$last_query = $_POST['query'];
$last_state = $_POST['state'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message = $first_name . " " . $last_name ." ".$last_number." ". $last_query." ".$last_state." ". " wrote the following:" . "
" . $_POST['message'];
$message2 = "Here is a copy of your message " . $first_name . "
" . $_POST['message'];
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
echo $mag="Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
// You can also use header('Location: thank_you.php'); to redirect to another page.
}
?>
You need to send Bcc
in headers only like below:
headers .= "Bcc: addess1,addess2,etc ";
you should try this format. also there is no bcc in your code
$headers = 'MIME-Version: 1.0' . "\\ ";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\\ ";
$headers .= 'To: test <test@example.com>, test1 <test1@example.com>' . "\\ ";
$headers .= 'From: test3 <test3@example.com>' . "\\ ";
$headers .= 'Cc: [email]test4@example.com[/email]' . "\\ ";
$headers .= 'Bcc: [email]test5@example.com,test6@myserver.com,test7@gmail.com,test8@email.com[/email]' . "\\ ";
mail($to, $subject, $message, $headers);