21

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

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

谢谢!

4

4 回答 4

33

将您的mailto 字段设置为null,然后$to在标题中内爆您的数组

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


mail(null, $title, $content, $headers);
于 2013-01-09T15:08:47.313 回答
0
$headers .= 'Bcc: mail@example.com' . "\r\n";
于 2013-01-09T15:09:08.827 回答
-2

CC 和 BCC 可以作为标头发送(参见: http: //php.net/manual/en/function.mail.php)。

您还可以使用其他邮件库 - PEAR Mail 库使发送电子邮件更加面向对象。http://pear.php.net/package/Mail/redirected

于 2013-01-09T15:08:39.597 回答
-3

请使用 pass Just Array 而不是做任何类型的 Implode、设置引号、逗号等。

例子:

    $bcc = array();

    foreach ($users as $user) 
    {
        $bcc[] = $user['User']['email'];
    }   

并将其传递给Mail函数:

        $email->from($from)
//            ->to($from)
              ->bcc($bcc)

谢谢,安基特帕特尔

于 2013-11-03T19:15:29.130 回答