Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php mail bcc multiple recipients

Tags:

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!

like image 299
user1936192 Avatar asked Jan 09 '13 15:01

user1936192


People also ask

How to send same email to multiple recipients using PHP?

To send an email to multiple recipients in PHP, we simply separate the emails using a comma. For example, mail("[email protected], [email protected]", SUBJECT, MESSAGE); To add CC and BCC in PHP mail, we have to manually set the “Cc” and “Bcc” fields in the mail headers.

How to add Cc in mail PHP?

"\r\n" . "CC: [email protected]"; mail($to,$subject,$txt,$headers);


1 Answers

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

$headers .= 'From: SmsGratisan.com <[email protected]>' . "\r\n"; $headers .= 'BCC: '. implode(",", $to) . "\r\n";   mail(null, $title, $content, $headers); 
like image 84
Mike Mackintosh Avatar answered Sep 24 '22 17:09

Mike Mackintosh