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? 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 = "[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}"); } ?> 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. 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... 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
Archived
This topic is now archived and is closed to further replies.