tekrscom Posted June 16, 2007 Share Posted June 16, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/55836-php-mail-to-multiple-recipients-from-query-result/ Share on other sites More sharing options...
chigley Posted June 16, 2007 Share Posted June 16, 2007 <?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}"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/55836-php-mail-to-multiple-recipients-from-query-result/#findComment-275842 Share on other sites More sharing options...
redarrow Posted June 16, 2007 Share Posted June 16, 2007 Tell me how this goes ok i love the mail function ok maybe i can inprove the current code for you ok. Quote Link to comment https://forums.phpfreaks.com/topic/55836-php-mail-to-multiple-recipients-from-query-result/#findComment-275862 Share on other sites More sharing options...
tekrscom Posted June 16, 2007 Author Share Posted June 16, 2007 Sorry it took so long to get back to you, it worked like a charm, thank you very much... Quote Link to comment https://forums.phpfreaks.com/topic/55836-php-mail-to-multiple-recipients-from-query-result/#findComment-275867 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.