Jump to content

php mail to multiple recipients from query result


tekrscom

Recommended Posts

Hi, I was wondering if anyone knows if there is a way to mail to mulitple recipients that are derived from a query?

 

$query = mysql_query("SELECT email FROM users WHERE title = 'Project Manager'");
while ($row  =  mysql_fetch_array($query))	{
	$manager_email = "$row[email]";
                    							}

$contactemail = $manager_email;
$headers .= "To: ".$contactemail."\r\n";

 

So how do you do this when there are more than one manager emails?

 

<?php

$from = "[email protected]";
$subject = "Message";
$body = "Hello!";

$query = mysql_query("SELECT email FROM users WHERE title = 'Project Manager'") or die(mysql_error());

while(list($email) = mysql_fetch_row($query)) {
mail($email, $subject, $body, "From: {$from}");
}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.