2012-08-15 83 views
0

我讀了使用PHP的郵件()做一個盲目的電子郵件?

所有自定義頁眉(如發件人,抄送,密送和日期)從PHP mail() reference支持

,但實際上,我怎麼在我的代碼實現這一點?即我不希望任何收件人看到其他電子郵件......永遠。

喜歡的東西:

<?php 
$to = "[email protected], [email protected], [email protected]"; 
$subject = "test message"; 
$msg = "this is a test"; 
$headers = "Bcc"; // <-- this? 

if (mail($to, $subject, $msg, $headers)) 
    echo "message sent"; 
else 
    echo "uh oh"; 
?> 

回答

3

看看頁面上的例子。

這裏有一個...

$headers .= 'To: Mary <[email protected]e.com>, Kelly <[email protected]>' . "\r\n"; 
$headers .= 'From: Birthday Reminder <[email protected]>' . "\r\n"; 
$headers .= 'Cc: [email protected]' . "\r\n"; 
$headers .= 'Bcc: [email protected]' . "\r\n"; 

所以你只需要添加逗號頭Bcc:後分隔的電子郵件地址。

這裏有一個用一個循環,將從陣列$recip地址添加到BCC:

$headers.="Bcc: "; 
while($count < $count_recip){ 
    $headers.=$recip[$count].", "; 
    $count ++; 
} 
+0

不要忘了你的手指,並希望在MTA剝離從消息中BCC頭。 – 2012-08-15 02:52:13

+0

感謝您的循環概念。這很簡單。 @Ignacio - 是的.. – khaverim 2012-08-15 03:16:15

0

添加地址到信封(即收件人列表),而不是信息(即標題)。

相關問題