hay i used this code
$to = "mial@live.com,mail@yahoo.com";
$subject = "Mini-mass Emailer";
$message = "<a href='#'>Hello World</a&g开发者_C百科t;";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Your Name <me@mydomain.com>' . "\r\n";
$headers .= 'Bcc: {$to}' . "\r\n";
if(mail($to, $subject, $message, $headers)){
echo 'ok';
}
but see what is happend every user see the full list of the users
alt text http://img694.imageshack.us/img694/1289/21811933.gif
Your call to mail is passing the $to as the to parameter meaning those emails will be be in the to header try passing an empty string instead. You are passing the info into the bcc header so the email should still get to them that way.
That is because you have put all the users in the "to" line. You are also passing them into the "bcc" line too so just doing this may help you but as far as I know you need at least one address in the to line (although this may not be the case). It'll look pretty strange for each person doing it that way though.
The best way to avoid these issues would be to send the email multiple times, once to each user. To modify your code example to do this, I'd do something like the following:
$toAddresses = array("mial@live.com", "mail@yahoo.com");
$subject = "Mini-mass Emailer";
$message = "<a href='#'>Hello World</a>";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Your Name <me@mydomain.com>' . "\r\n";
foreach ($toAddresses as $to) {
if(mail($to, $subject, $message, $headers)){
echo "OK - sent message to {$to}";
}
}
The easiest way is to take this Mail-Class of phpguru.org: http://www.phpguru.org/static/htmlMimeMail5
There you can specify with setBcc() the addresses which should be "blind", it's pretty easy and works well. I use this class in every project.
Best Regards.
精彩评论