PHP Mail, Cc Field

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



Leave a reply



Submit