在PHP邮件功能中包含cc

时间:2012-11-16 09:24:29

标签: php html-email email-formats

当我试图使用php邮件功能插入cc时,我只收到带有HTML部分的消息。

我正在使用以下代码

      $headers  = "From:someone@gmail.com\r\n";
      $headers .= "CC:test@gmail.com\r\n"; 
  $headers .= "Content-type: text/html\r\n"; 
  $to ="$x_email";
  $subject ="Your Order Confirmation";
      $bodyadmin=$messageadmin;
  $sentmail=mail($to, $subject, $bodyadmin, $headers);

有人可以帮我解决这个问题吗?

2 个答案:

答案 0 :(得分:1)

$headers = "From: $from_email\r\nReply-To: $from_email";
$headers .= 'Cc: test@test.com\r\n';
$headers .= "Content-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";

答案 1 :(得分:1)

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";