Posted By

benphelps on 08/10/08


Tagged

email mysql loop mass


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

benphelps
fackz
vali29


Loop email reading MySQL


 / Published in: PHP
 

URL: http://phelps.impactwow.com

  1. <?php
  2. set_time_limit(0);// this will keep the script from stopping if it takes longer then 30 seconds, must have this here
  3. mysql_connect("localhost", "root", "pass");
  4. mysql_select_db("database");
  5. $query = mysql_query("SELECT email FROM account");
  6. $emailsubject = "This is a sample subject!";
  7. $emailbody = file_get_contents("email.html");
  8. $fromaddress = "[email protected]";
  9.  
  10.  
  11. // here we loop through the mysql array until we reach then end
  12. while ($row = mysql_fetch_array($query, MYSQL_NUM))
  13. {// start while
  14.  
  15. // we use the sql var. $row and we use the field 0 to pickup the email address
  16. mail($row[0], $emailsubject, $emailbody, "From: " . $fromaddress . "\nX-Mailer: PHP 4.x");
  17.  
  18. }// end while
  19.  
  20. ?>

Report this snippet  

You need to login to post a comment.