Hi all,

Please help me how to add CC and BCC in this code section of form to mail using PHP

<?php

  //send email

  $from = 'enquiry@techxis.com';
  $name = $_REQUEST['txtName'];
  $company = $_REQUEST['txtCompanyName'];
  $jobTitle = $_REQUEST['txtJobTitle'];
  $email = $_REQUEST['txtEmail'] ;
  $contactNo = $_REQUEST['txtContactNo'] ;
$email = $_REQUEST['txtEmail'] ;
  $subject = $_REQUEST['txtSubject'] ; 
  $msg = $_REQUEST['txtMessage'] ;
  $message= " Name : " .$name." \n Company : ".$company." \n Contact Number :".$number." \n Email : ".$email." \n Message : ".$msg;
 $mailsent= mail("parasarashlov@gmail.com", "$subject",
  $message, "From:" . $from);
if($mailsent)
   $msg1="Mail sent succefully";
else
   $msg1="Error occured while sending mail";
 
echo "<script>window.location = 'contactus.html?message={<?php echo $msg1;?>}'</script>"; 
exit;
?>

Please help me as soon as possible.

Thanks and Regards
Nikita Chandra

Read additional_headers in php mail function.

You can do something like this :

$headers = '';
$headers .= 'From: ' . $from . "\r\n";
$headers .= 'Cc: ccemail@example.com' . "\r\n";
$headers .= 'Bcc: bccemail@example.com' . "\r\n";
$mailsent= mail("parasarashlov@gmail.com", "$subject", $message, $headers);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.