Kristoff1875 Posted March 6, 2015 Share Posted March 6, 2015 If i've got a database of users that have filled out a form, can I use a cron job to send an automated email? If so, what is the best way to "loop" it so that it sends the email once to each user? $data = mysql_query(" SELECT * FROM completed WHERE followupsent='0000-00-00 00:00:00' AND valuesent + INTERVAL 4 DAY <= NOW() ") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { } This checks to see if "followupsent" has been updated already as it updates with NOW() when it sends and also checks to see how many days since the value was sent. I'm worried that by putting the email sending information in the while tags is going to loop for each row and end up sending a ton of emails. Would using if($info = mysql_fetch_array( $data )) { } Send out to the first in the database and then the CRON Job handle the rest by checking every minute which one is next? Cheers Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.