[英]php mail bcc multiple recipients
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 <admin@website.com' . "\r\n";
mail(implode(',', $to), $title, $content, $headers);
Thanks!谢谢!
Set your mail
to field to null
, and then implode your $to
array in your headers将您的
mail
到字段设置为null
,然后在您的标题中内爆您的$to
数组
$headers .= 'From: SmsGratisan.com <admin@website.com>' . "\r\n";
$headers .= 'BCC: '. implode(",", $to) . "\r\n";
mail(null, $title, $content, $headers);
$headers .= 'Bcc: mail@example.com' . "\r\n";
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.您还可以使用其他邮件库 - PEAR 邮件库使发送电子邮件更加面向对象。 http://pear.php.net/package/Mail/redirected
http://pear.php.net/package/Mail/redirected
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 Mail
Function:并将此传递给
Mail
功能:
$email->from($from)
// ->to($from)
->bcc($bcc)
Thanks, Ankit Patel谢谢,安基特帕特尔
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.