$sql = "select emailid from table where category = 1";
while($row=mysql_fetch_array($sql))
{
$email=$row['emailid'];
$to = $email;
$subject = "E-mail subject";
$body = "E-mail body";
$headers = 'From: info@mydomain.com' . "\r\n" ;
$headers .= 'Reply-To: info@mydomain.com' . "\r\n";
mail($to, $subject, $body, $headers);
}
Suppose the above code will fetch 100 e-mail ids from database and send the mail one by one to each e-mail id. but what i want to do is…. fetch all e-mail ids in an array and send them as ‘BCC’ to each e-mail at once. one more thing i want to customize the e-mail body content for each id….
Any ideas?
What you want to do is impossible. If you send them at once via multiple addresses in To/CC/BCC, everyone gets exactly the same email. So you cannot customize the bodies.
If sending the same email to everyone is fine, try this: