0

我读到了

支持所有自定义标题(如 From、Cc、Bcc 和 Date)

来自PHP mail() 参考,但我如何在我的代码中实际实现这一点?即我不希望任何收件人看到其他电子邮件......永远。

就像是:

<?php
$to = "someguy@somesite.com, another@abc.com, someother@def.com";
$subject = "test message";
$msg = "this is a test";
$headers = "Bcc"; // <-- this?

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

2 回答 2

3

查看页面上的示例。

这是一个...

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

Bcc:因此,您只需在标题后添加逗号分隔的电子邮件地址。

这是一个带有循环的循环,它将数组中的地址添加$recip到密件抄送:

$headers.="Bcc: "; 
while($count < $count_recip){ 
    $headers.=$recip[$count].", "; 
    $count ++; 
} 
于 2012-08-15T02:51:18.443 回答
0

将地址添加到信封(即收件人列表),而不是邮件(即标题)。

于 2012-08-15T02:51:16.383 回答