Here is the summary of my problem.
I have a newsletter application in PHP in which I query the user database(which has on growing users...right now 40,000 users) to get the email addresses and query the newsletter table to attach the content and send emails. All this functionality is in one PHP page which runs everyday at some time using CRON job. Now the problem is when this program runs, in a few minutes the mail server will be flooded with queued emails. Since our server is a shared server(Apache/Linux), all other clients cry because of the mail delivery delay.
The mail sending page has one loop to iterate the users and inside that mail() function. I don't know what else I can do to avoid this flooding in the mail server...Can I create some delay in sending the emails? Will it help?
Your suggestion are greately appreciated.