title: PHP Send email to multiple address from SQL
body: <p>I'm trying to send emails to multiple address pulled from SQL. I came up with following script but no luck. I know that using <code>mail()</code> or <code>sendmail</code> is not best choice, if anybody can point out where I went wrong or have a better solution using phpmailer that would be brilliant. </p>
  
  <p>PS: I do not want to use SMTP as we are using an address that we will not be monitoring. The Do-NOT-REPLY one, actually we don't have email service at all. But server does support mail/sendmail/phpmailer, all tested.</p>
  
  <pre><code>&lt;HTML&gt; 
     &lt;TITLE&gt;Email Notification&lt;/TITLE&gt; 
  &lt;?php
  
  include "subscribe/mySQL.class.php"; //Connect to SQL 
  
  if ($subject) { 
      $mailaddress = "DO-NOT-REPLY@domain.my";
      $query = "select email from subscribe"; 
      $res = mysql_query($query); 
      $row = mysql_fetch_array($res); 
  
      while ($row) { 
  
          mail($row['email'],$subject,$text."n ","From:".$mailaddress); 
          $row = mysql_fetch_array($res);
  
      } 
  
      echo "&lt;script type='text/javascript'&gt;"; 
      echo "parent.location.href='welcome.php'"; 
      echo "&lt;/script&gt;";} 
  ?&gt; 
  &lt;BODY&gt; 
  &lt;P ALIGN=CENTER&gt;&lt;FONT FACE="Arial" SIZE="7" COLOR="#FF0000"&gt;Send Notifications&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt; 
  &lt;P ALIGN=LEFT&gt;&lt;FORM NAME="email" ACTION="test.php" METHOD="POST"&gt; 
  &lt;FONT FACE="Arial" SIZE="6" COLOR="#0000FF"&gt;Subject:&lt;INPUT TYPE=TEXT NAME="subject" SIZE="50" MAXLENGTH="18" value=&lt;?php echo $subject ?&gt;&gt;&lt;BR&gt;&lt;BR&gt; 
  Content: &lt;TEXTAREA NAME="text" COLS="90" ROWS="3" value="&lt;?php echo $text?&gt;"&gt; &lt;/TEXTAREA&gt;&lt;BR&gt;&lt;BR&gt; 
  &lt;/FONT&gt; 
  &lt;INPUT TYPE=SUBMIT VALUE=Send Email&gt;&lt;/FORM&gt; 
  &lt;/BODY&gt; 
  &lt;/HTML&gt;
  </code></pre>