include cc in php mail function

1.5k Views Asked by At

When I`m trying to insert cc with the php mail function I get only message with the HTML part.

I`m using the following code

      $headers  = "From:[email protected]\r\n";
      $headers .= "CC:[email protected]\r\n"; 
  $headers .= "Content-type: text/html\r\n"; 
  $to ="$x_email";
  $subject ="Your Order Confirmation";
      $bodyadmin=$messageadmin;
  $sentmail=mail($to, $subject, $bodyadmin, $headers);

Could any one please help me to solve this issue?

2

There are 2 best solutions below

1
On
$headers = "From: $from_email\r\nReply-To: $from_email";
$headers .= 'Cc: [email protected]\r\n';
$headers .= "Content-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
0
On
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Mary <[email protected]>, Kelly <[email protected]>' . "\r\n";
$headers .= 'From: Birthday Reminder <[email protected]>' . "\r\n";
$headers .= 'Cc: [email protected]' . "\r\n";
$headers .= 'Bcc: [email protected]' . "\r\n";