I was just wondering if the sleep() function would have any effect on a high volume (700 – 3000 loops) mail() loop.
So maybe after every ten loops, sleep for a few seconds then do another 10, and so on…
Would that help make the loop more efficient?
Just curious guys!
I would make each email a job in a queue system like Gearman (as it has PHP bindings) instead of merely putting them in a loop. This way you avoid the PHP process timing out etc if the mail function holds things up.
In the past I have used the Linux
atcommand (a simple queue mechanism) to achieve this with a PHP wrapper script that I wrote: PHP-at-Job-Queue-Wrapper.I do not think that
sleep()would be a good way of making this more efficient or transparent.