cc在php邮件中无法正常工作

I am using this code to send a form with uploaded file. However It is working fine with primary mail but do not send cc mail.

    $headers = "From: $email";
    $headers .= 'Cc: xyz@gmail.com' . "
";

    // create a boundary string. It must be unique
      $semi_rand = md5(time());
      $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

      // Add the headers for a file attachment
      $headers .= "
MIME-Version: 1.0
" .
                  "Content-Type: multipart/mixed;
" .
                  " boundary=\"{$mime_boundary}\"";

please help me to make it run. thanks

u have to try this way

    $headers =  'From: webmaster@example.com' . "
" ;
    $headers .= 'Cc: xyz@gmail.com' . "
";

CC in the headers is nice, but it doesn't actually cause it to get sent to the end-user. You need to provide in the mail() function in the $to value, the addresses of the additional people you want to receive a copy of the email. This includes To, CC and BCC.

There is a very nice CC and BCC example here: http://php.net/manual/en/function.mail.php

You have missed a line feed after the first header line

$headers = "From: $email";
$headers .= 'Cc: xyz@gmail.com' . "
";

This will output From: $emailCc: xyz@gmail.com in your header - add a line break on first line

What really worked for me was to create 2 variables "$to" and "$recipients". Inside the $recipients variable you concatenate the $cc variable like this:

$recipients = $to . ", " . $cc;

                        $headers = array ('From' => $from,
                                          'To' => $to,
                                          'Cc' => $cc,
                                          'Subject' => $subject,
                                          'MIME-Version' => 1,
                                          'Content-type' => 'text/html;charset=iso-8859-1');

$mail = $smtp->send($recipients, $headers, $message);

Hope this helps!