PHP Mail, CC Field
Add this while declaring headers:
$headers .= 'Cc: somebody@example.com' . "\r\n";
PHP insert cc into mail function
just tested this, and it worked as expected:
$headers .= 'Cc: test@test.com\r\n';
$headers .= 'Bcc: test@test.com\r\n';
I would also suggest moving your carriage return and new line to the end of the previous entry to $headers
$headers = "From: $from_email\r\nReply-To: $from_email";
$headers .= 'Cc: test@test.com\r\n';
$headers .= 'Bcc: test@test.com\r\n';
$headers .= "Return-Path: <info@premierinspectiontn.com>\r\n";
// add boundary string and mime type specification
$headers .= "Content-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
hope that helps
How to add a cc in a php contact form?
Here is your sample code
$to = "xyz@somedomain.com";
$subject = "This is subject";
$message = "<b>This is HTML message.</b>";
$message .= "<h1>This is headline.</h1>";
$header = "From:abc@somedomain.com \r\n";
$header .= "Cc:afgh@somedomain.com \r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html\r\n";
$retval = mail ($to,$subject,$message,$header);
if( $retval == true ) {
echo "Message sent successfully...";
}else {
echo "Message could not be sent...";
}
PHP send email BCC & CC using SMTP
The carbon copy is an header.
All recipients are recipients in the same way for the mail server, the difference between carbon copy and blind carbon copy is just a matter of declaring it in the headers.
$headers = array(
'Port' => $port,
'From' => $from,
'To' => $to,
'Subject' => $subject,
'Content-Type' => 'text/html; charset=UTF-8',
'Cc' => $cc
);
Related Topics
How to Efficiently Find the Closest Locations Nearby a Given Location
Run Composer with a PHP Script in Browser
PHP Return Only Duplicated Entries from an Array
How Get Value for Unchecked Checkbox in Checkbox Elements When Form Posted
Symfony2 and Date_Default_Timezone_Get() - It Is Not Safe to Rely on the System's Timezone Settings
PHP Replacing Special Characters Like à->A, è->E
Laravel Orderby Relationship Count
Bounce Email Handling with PHP
Select Outgoing Ip for Curl Request
How to Get PHP to Produce a Backtrace Upon Errors
Php: Possible to Automatically Get All Posted Data
How to Display a Date as Iso 8601 Format with PHP
What Does a Successful MySQL Delete Return? How to Check If Delete Was Successful
What Causes: "Notice: Uninitialized String Offset" to Appear
Regex for Names with Special Characters (Unicode)