php mail bcc multiple recipients

丶灬走出姿态 提交于 2019-11-28 10:46:45

Set your mail to field to null, and then implode your $to array in your headers

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

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

Ankit K Patel

Please use pass Just Array instead of doing any kind of Implode, Set quotes, comma etc.

Example:

    $bcc = array();

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

And pass This To Mail Function:

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

Thanks, Ankit Patel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!