3

Possible Duplicate:
PHP Mail, CC Field

I am using the following php to send an email. I need to add cc to my email. When I try to insert into header the html message show the raw html. What is the best way to handle a cc?

Thanks

$headers = "From: $from_email\r\nReply-To: $from_email";

$headers .= "Return-Path: <info@premierinspectiontn.com>";

//add boundary string and mime type specification
$headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
Community
  • 1
  • 1
rstewart
  • 465
  • 2
  • 8
  • 17

2 Answers2

17

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

Adeel
  • 2,901
  • 7
  • 24
  • 34
Shawn Barratt
  • 472
  • 3
  • 9
  • 1
    Thanks for your reply. I tested your code and the email message body worked but the cc didn't get sent. Any ideas what could be the cause? – rstewart Jan 28 '12 at 05:44
  • If you look at the raw header information, do you see the cc there? Would it be possible to post the headers? – Shawn Barratt Jan 28 '12 at 12:47
  • I decided to start the page from scratch redo the page and took off the cc and this is the email message:
    --PHP-alt-0603545d439904956b8f20136436ede1 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Hello World!!! This is simple text email message. --PHP-alt-0603545d439904956b8f20136436ede1 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: 7bit

    Hello World!

    This is something with HTML formatting.

    --PHP-alt-0603545d439904956b8f20136436ede1--
    – rstewart Jan 28 '12 at 15:19
  • CC did not work for me either – Debbie Kurth May 23 '22 at 03:53
1

Try adding

$headers .= 'CC: other@url.com' . "\r\n";
Paul Dessert
  • 6,363
  • 8
  • 47
  • 74