如何制作密送邮件? 如果我发送该邮件,它会向我显示所有收件人!
$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);
谢谢!
答案 0 :(得分:26)
将mail
字段设置为null
,然后在标题中内嵌$to
数组
$headers .= 'From: SmsGratisan.com <admin@website.com' . "\r\n";
$headers .= 'BCC: '. implode(",", $to) . "\r\n";
mail(null, $title, $content, $headers);
答案 1 :(得分:0)
$headers .= 'Bcc: mail@example.com' . "\r\n";
答案 2 :(得分:-1)
CC和BCC可以作为标题发送(参见:http://php.net/manual/en/function.mail.php)。
您还可以使用其他邮件库 - PEAR邮件库使发送电子邮件更加面向对象。 http://pear.php.net/package/Mail/redirected
答案 3 :(得分:-2)
请使用传递Just Array而不是进行任何种类的Implode,Set quotes,逗号等。
示例:
$bcc = array();
foreach ($users as $user)
{
$bcc[] = $user['User']['email'];
}
并将此传递给Mail
功能:
$email->from($from)
// ->to($from)
->bcc($bcc)
谢谢, Ankit Patel