从MySql Recordset向多个收件人发送电子邮件

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:

<?php 

$recipients = ("SELECT email FROM tblMembers WHERE search criteria=criteria"); 
$email_list = $db->query($recipients); 
foreach($email_list as $row) { 
$to = $row['email']; 
$subject = "Membership Renewal";
$headers = "From: Membership Coordinator <membership@myaddress.net>
";
$message = "THIS IS AN AUTOMATED EMAIL.  PLEASE DO NOT REPLY""
""etc, etc, etc";
  if ( mail($to,$subject,$headers,$message) ) {
   echo "Email was sent successfully";
   } else {
   echo "Email delivery has failed!";
   }
} 
?> 

As far as I know, then $headers comes after $message, so you should just change the order in mail() and be more aware in future.

Change

$message = "THIS IS AN AUTOMATED EMAIL.  PLEASE DO NOT REPLY""
""etc, etc, etc";

to

$message = "THIS IS AN AUTOMATED EMAIL.  PLEASE DO NOT REPLY
etc, etc, etc";

There is the syntax error, because " will end the string. You would need a . to concatenate the next string.

But you could also leave the two " out at this point, becase in a double quoted string, PHP will replace by a newline character.