I came up with a schema for a simple batch email I’m making. The emailer will send out X number of emails every 5 minutes by running a cron job’d php script. The issue is that I don’t think this is the best way to do it, and was looking for an alternate, better way; or validation ;).
The (simplified) schema would look like:
EmailList | JobQue | Jobs
------------|----------|----------
email | jobid | id
| email | esubject
| ebody
The idea is that when a new job is created, it adds it to the Jobs table, and every email that needs to be sent will be added to the JobQue table.
Then the cron’d php script actually sending the emails will just loop through the next X number of items in the JobQue table, send and delete them.
Is this a good way of doing it? Will it buckle under moderate load? (1000-5000 emails, 1-5 jobs a day)? Of course it would if there are more emails being added then sent, but would there be other issues (like trying to add a 1000 records to a table in one go, even if I’m inserting them all with one mysql query)?
Thanks,
Max
I think this is a very effective way of doing it. The only issue could be, if you want to send like thousands of emails at once. It could lead to timeout in php.
Adding thousends of records into mysql with one query is not bad, it’s the best way imo.
But I must say, the copy depends on the query itself. If it is too long (I mean a too long string), than you can loose the connection to the server.
But I don’t think you will have any problems with this schema at all.