How can I send mail to multiple users without the users knowing eachother's emails using PHP?
What I have is this:
$SQL = "SELECT * FROM users";
$query = mysql_query($SQL) OR die(mysql_error());
$row = mysql_fetch_array($query);
$implodeEmail = implode(", ", $row['paypal']);
$mailTo = "noreply@" . $_SERVER['HTTP_HOST'];
$mailSubject = $bootTitle;
$mailMessage = $_POST['massemail'];
$mailHeaders = "From: noreply@" . $_SERVER['HTTP_HOST'] . "\r\n" .
"Reply-To: noreply@" . $_SERVER['HTTP_HOST'] . "\r\n" .
"X-Mailer: PHP/" . phpve开发者_运维知识库rsion() . "\r\n" .
"Bcc: " . $implodeEmail;
if (mail($mailTo, $mailSubject, $mailMessage, $mailHeaders))
{
echo "e-Mail successfully sent.";
}
It successfully sends to the $mailTo, but I want it to Bcc to everyone's paypal email, and that isn't working. I thought about just making all emails visible, but I really don't want that, and I don't want to loop through each one and send out an email for each person.
Ideas/help?
just a rough idea:
$implodeEmail = implode("; ", $row['paypal']);
or just noticed that instead of:
$row = mysql_fetch_array($query);
$implodeEmail = implode(", ", $row['paypal']);
should be:
while($row=mysql_fetch_array($query)) $rows[]=$row['paypal'];
$implodeEmail = implode(", ", $rows);
If you include all the addresses in the Bcc header, the server should send a copy to each one. If he doesn't do that, something is wrong with the server. Look in the php.ini mail config, and test your mailserver. And yeah, you should use ";" instead of "," to implode the addresses.
Try phpMailer or SwiftMailer.
精彩评论