I am building a website where 开发者_如何学Cusers will be able to send newsletters. They will need to track the sending process and also to stop it if required. Since they may have lots of emails the actual sending will be delegated to a script which will run in the background and will be executed by the user. This script will handle all users' newsletters, only the arguments to it will be different.
For the user to be able to see how many mails have been sent and to stop the sending process I was thinking of implementing some sort of interprocess communication between the website and the scripts running in the background but I'm not sure how to do it.
Any help will be much appreciated.
The process:
- When sending the newsletter, queue all target addresses in a table.
- Process a fix amount of the queue in a cronjob that runs every few minutes.
Then when displaying sent amount, just count the amount of entries in your queue that are processed.
When working with a queue will also fix any performance issues your script encounters when everyone clicks 'send' simultaneously.
Stop mailing
If the customer would like to stop mailing, you only have to remove all queue'd emails where the mailing matches. You could also flag them as 'cancelled' if you would like to keep the data. (You will have to make sure your queue only processes 'pending' mails from the queue).
精彩评论