Jump to content

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 = "noreply@yoursite.com";
$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}");
}

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.