How to add a BCC list using the PHPMailer class
It's much faster, if you are sending out a lot of emails, to send the email to one person (yourself, perhaps) and blind copy it to everyone else.
Some people seem to struggle with getting the PHPMailer class to add a BCC list but it is actually very simple:
Let's assume that you have your list of BCC recipients in an array. In this example, they are in the array $list
Simply loop through the array and call the PHPMailer function AddBCC():
$mail->AddBCC($bccer);
}
And that's it. Simple, eh?
Creating a BCC list as an array
Simply use PHP's array() function:
Creating a BCC list as an array from a database
This is also straight-forward and there are a few ways of extracting data into an array but I think this one is the easiest to follow:
$result = mysql_query($sql) or die("Invalid query: " . mysql_error());
$num=mysql_numrows($result);
$y=0;
while($y < $num){
$list[$y]=mysql_result($result,$y,"emailaddress");
$y++;
}
Primer, sealer, dust proofing coating
Larkrise Sealcote is a multi-purpose, clear,
water-based coating - Dilute 2:1 and solve a number of problems
Tweet about this!