php 邮件密件抄送 多个收件人

2022-08-30 20:01:58

如何制作密件抄送邮件?如果我发送该邮件,它会向我显示所有收件人!

$to=array();
$members_query = mysql_query("select email from members");
while( $row = mysql_fetch_array($members_query) )
{
    array_push($to, $row['email']);
}

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";

// Additional headers
//$headers .= 'To: '.$newName.' <'.$newEmail.'>' . "\r\n";
$headers .= 'From: SmsGratisan.com <admin@website.com' . "\r\n";


mail(implode(',', $to), $title, $content, $headers);

谢谢!


答案 1

将 to 字段设置为 ,然后在标头中内爆数组mailnull$to

$headers .= 'From: SmsGratisan.com <admin@website.com>' . "\r\n";
$headers .= 'BCC: '. implode(",", $to) . "\r\n";


mail(null, $title, $content, $headers);

答案 2
$headers .= 'Bcc: mail@example.com' . "\r\n";

推荐