2014-06-26 49 views
0

好的,這是我的,我需要得到這個地方它將發送到電子郵件地址電子郵件盲CC。想法?我曾嘗試使用$ BCC選項,它似乎不適用於我。我寧願讓它每個人都不知道它會發生什麼。在PHP的郵件功能中添加BCC

<?PHP 
$to = "[email protected]; [email protected]"; 
$subject = "Subject"; 
$headers = "who it's from"; 
$forward = 1; 
$location = "Thank you Address.html"; 

$date = date ("l, F jS, Y"); 
$time = date ("h:i A"); 



$msg = "Below is the result of your feedback form. It was submitted on $date at $time.\n\n"; 

if ($_SERVER['REQUEST_METHOD'] == "POST") { 
    foreach ($_POST as $key => $value) { 
     $msg .= ucfirst ($key) ." : ". $value . "\n"; 
    } 
} 
else { 
    foreach ($_GET as $key => $value) { 
     $msg .= ucfirst ($key) ." : ". $value . "\n"; 
    } 
} 

mail($to, $subject, $msg, $headers); 
if ($forward == 1) { 
    header ("Location:$location"); 
} 
else { 
    echo "Thank you for submitting our form. We will get back to you as soon as possible."; 
} 

?> 

確定這就是我已經試過,它似乎仍然沒有奏效,我知道我失去了一些東西的地方。我知道,當我終於可以將它作爲密送發送給我時,我希望它可以發送與其他人相同的主題以及來自誰的密送。

$to = "[email protected]"; 
$subject = "subject1"; 
$headers = 'Bcc: [email protected]' . "\r\n"; 
$headers = 'From: Complaint' . "\r\n"; 
$forward = 1; 
$location = "thank-you.html"; 

    $date = date ("l, F jS, Y"); 
    $time = date ("h:i A"); 
+0

「我嘗試過使用$ BCC選項,它似乎不適合我。」你能詳細解釋一下嗎? –

+0

看看這個類似的問題http://stackoverflow.com/questions/15184267/i-want-to-use-bcc-or-cc-function-in-this-mail-function?rq=1 – dmullings

+0

這是真的值得避免直接調用'mail()'。該腳本已經容易受到頭部注入攻擊,並且很可能會遇到編碼問題。使用電子郵件庫。 – Synchro

回答

0

問題是你重寫$頭的值,使用=第二次。 試試看:

$to = "[email protected]"; 
$subject = "subject1"; 
$headers = 'Bcc: [email protected]' . "\r\n"; 
$headers .= 'From: Complaint' . "\r\n"; 
$forward = 1; 
$location = "thank-you.html"; 

    $date = date ("l, F jS, Y"); 
    $time = date ("h:i A"); 

請享受您的代碼!