I have built my own email subscription tool and for small runs of emails; a couple of hundred or less; it all works fine.
The issue I am having is when a large number of emails are sent the server times out before everything is sent or a client is closing the browser before the send is finished.
Currently I am just using a WHILE loop and the PHP MAIL function and sending an individual email to each person.
Does anyone know a way or can make any suggestions on how to can fix this issue?
I don't know the details of how you have things set up, but IMHO ideally this would be CRON run and be independant from a "browser closing". So I'm guessing the code is run in a page?
You could try ignore_user_abort() but be warned, and endless loop condition would wreak havoc.
For the larger iterations, you could try BCC in batches instead of 1 each loop.
Thanks for your reply.
I had thought of running it as a separate file but I think I would have the same issue with the timeouts. Wouldn't I?
BCC will not really work as I want the option to personalise each email.
Thinking about it would a FOREACH statement work better than a WHILE statement as far as speed?
Any other suggestions?
I would just run them in batches. Send 100, refresh the page, and send another 100. Also, isn't there a variable you can change in your php.ini about timeouts? Not sure myself...