Loop email reading MySQL


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  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. ?>

URL: http://phelps.impactwow.com

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.