php php邮件密件抄送多个收件人
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14238207/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
php mail bcc multiple recipients
提问by user1936192
How do I make a bcc mail? If I send that mail, It shows me all the recipients!
我如何制作密件抄送邮件?如果我发送那封邮件,它会显示所有收件人!
$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 <[email protected]' . "\r\n";
mail(implode(',', $to), $title, $content, $headers);
Thanks!
谢谢!
回答by Mike Mackintosh
Set your mailto field to null, and then implode your $toarray in your headers
将您的mailto 字段设置为null,然后$to在您的标题中内爆您的数组
$headers .= 'From: SmsGratisan.com <[email protected]' . "\r\n";
$headers .= 'BCC: '. implode(",", $to) . "\r\n";
mail(null, $title, $content, $headers);
回答by FlourishDNA
$headers .= 'Bcc: [email protected]' . "\r\n";
回答by dethtron5000
CC and BCC can be sent as headers (see: http://php.net/manual/en/function.mail.php).
CC 和 BCC 可以作为标题发送(参见:http: //php.net/manual/en/function.mail.php)。
You can also use other mail libraries - the PEAR Mail library makes sending emails a little more object-oriented. http://pear.php.net/package/Mail/redirected
您还可以使用其他邮件库 - PEAR 邮件库使发送电子邮件更加面向对象。http://pear.php.net/package/Mail/redirected
回答by Ankit K Patel
Please use pass Just Array instead of doing any kind of Implode, Set quotes, comma etc.
请使用 pass Just Array 而不是做任何类型的内爆、设置引号、逗号等。
Example:
例子:
$bcc = array();
foreach ($users as $user)
{
$bcc[] = $user['User']['email'];
}
And pass This To MailFunction:
并将此传递给Mail函数:
$email->from($from)
// ->to($from)
->bcc($bcc)
Thanks, Ankit Patel
谢谢,安基特帕特尔

