title: Sending Email to Multiple Recipients from MySql Recordset
body: <p>I want to send an email to multiple recipients using PHP mail() function.  The email message is simply a reminder that a membership is due to expire so email addresses will come from MySql database query.  There would anywhere from 2-10 at any given time.  I found the following code but it generate errors.  The problem is not with my query as it generates an accurate recordset.  This is the code I have:  Hopefully someone can help.  By the way, I am very much a novice so need easy straight forward explanation.  Thanks in advance:</p>
  
  <pre><code>&lt;?php 
  
  $recipients = ("SELECT email FROM tblMembers WHERE search criteria=criteria"); 
  $email_list = $db-&gt;query($recipients); 
  foreach($email_list as $row) { 
  $to = $row['email']; 
  $subject = "Membership Renewal";
  $headers = "From: Membership Coordinator &lt;membership@myaddress.net&gt;\r\n";
  $message = "THIS IS AN AUTOMATED EMAIL.  PLEASE DO NOT REPLY""\n""etc, etc, etc";
    if ( mail($to,$subject,$headers,$message) ) {
     echo "Email was sent successfully";
     } else {
     echo "Email delivery has failed!";
     }
  } 
  ?&gt; 
  </code></pre>