PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I want to send weekly emails to few thouthands users who are students..(lessons schedule + some additional info)
each email message might be as large as ~3mg(in some cases there will be an attachements in form of images).
Say,i use mail() function in loop. There are going to be a few thouthands of iterations. during each iteration there is some work to be done for generating email... it takes time...
I have doubts if it is a proper approach in this case
it seems to me that such a script will be simply timed out...(max_execution_time) or system at some point will deny any additional requests...
What do you think is the proper way to handle such situation?
thanks
hum......maybe not the most efficient way but off the top of my head...say on the first call of the page count the rows and store how many rows there are in a field somewhere.then do the first twenty.on each call after that check where you are and where you need to be. do 20 each call of the page until you get to the number you need to be at then set a flag saying your done for that week (in the database obviously).of course you'll need to check for that flag each loop before starting anything.and then have a cron job call the page every fifteen minutes or so(maybe less?). and to make the coup de grace when it's finished (the flag exists) have it e-mailing you telling you to go delete the cron job i dunno..that's just off the top of my head:-D
edit: if anyone has a better idea please feel free to laugh at me as you explain a better way;)
i used a cron job when taking over 2000 requests off of a server to build a advertising database/website. if i had just looped the whole thing i would have gotten banned but when i just made 4 requests every 5 minutes it worked fine.
recently i used a cron job every day at 12 to change a "expired" account to a guest account and send the user a email to notify them.
could check out phpmyemaillist ( I think) or phpmailinglist or something by a similar name at sourceforge.net .. I havent worked on it in a *LONG* time, however when I got involved with it, I took the code and adapted it to run on a cron, which it then sent our to a mailing list of over 35,000 over a 12 hour period (and if you use phpmailer class, you can also load balance by sending email "jobs" to multiple smtp servers, easing the overall load..)