2013-11-27 65 views
1

我正在使用此代碼發送帶有上傳文件的表單。然而,它與主郵件正常工作,但不發送cc郵件。cc在php郵件不起作用

$headers = "From: $email"; 
    $headers .= 'Cc: [email protected]' . "\r\n"; 

    // 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 .= "\nMIME-Version: 1.0\n" . 
        "Content-Type: multipart/mixed;\n" . 
        " boundary=\"{$mime_boundary}\""; 

請幫助我使它運行。謝謝

回答

3

u必須嘗試這種方式

$headers = 'From: [email protected]' . "\r\n" ; 
    $headers .= 'Cc: [email protected]' . "\r\n"; 
+0

謝謝你的解決方案 – techansaari

+0

upvote如果你有解決方案.. –

+0

upvote被鎖定,如果你編輯解決方案,我會做到這一點。 – techansaari

-1

CC在標題是好的,但它並不實際上導致它發送到最終用戶。您需要在$tomail()函數中提供您希望收到該電子郵件副本的其他人的地址。這包括To,CC和BCC。

有一個非常漂亮的CC和BCC例如這裏:http://php.net/manual/en/function.mail.php

+0

這是不正確的。該文件明確指出,Cc和密件抄送必須包含在'$ additional_headers參數' – Angelo

0

真正爲我工作的是創建2個變量「$ to」和「$ recipients」。在$ recipients變量中,你連接$ cc變量,像這樣:

$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); 

希望這有助於!