scooter41 Posted October 16, 2007 Share Posted October 16, 2007 Hi there, I am trying to create a script for a client that has just over 90,000 users in a mysql database that they want to send out a monthly newsletter. I am simply using a looping script from a mysql query, like the following: while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) { sendmailer($row['email'],$numrows,$row['code1'],$row['code2']); } } Then have a sendmailer function to sendout the html email they provide. It seems to get to around the 27,000 figure fine then seems to stop sending out any further emails... Do you think this is due to any kind of timeout, or perhaps an invalid data entry? if there a more gracefully / error trapping way of doing this? Thanks for any help in advance Scott Quote Link to comment Share on other sites More sharing options...
MadTechie Posted October 16, 2007 Share Posted October 16, 2007 Why not just, send 1 email, create an account for yourself ie mailer@domain.com then send 1 email to that and BCC everyone in that list, this will protect their email address from other and reduce stress on the server! Quote Link to comment Share on other sites More sharing options...
scooter41 Posted October 16, 2007 Author Share Posted October 16, 2007 I didnt think the mail server would like receiving 90,000 BCC fields would it? Surely that would make it fall over? I know on another server I am using it has a maximum limit of 50 email addresses per message Quote Link to comment Share on other sites More sharing options...
MadTechie Posted October 16, 2007 Share Posted October 16, 2007 either that or have an half an hour break.. 90k of emails is classed as an e-Bomb! Quote Link to comment Share on other sites More sharing options...
scooter41 Posted October 16, 2007 Author Share Posted October 16, 2007 Sure is..... but hey, customers are customers...... Quote Link to comment Share on other sites More sharing options...
scooter41 Posted October 16, 2007 Author Share Posted October 16, 2007 thinking about your idea though, I guess I could send in blocks of 50 emails at a time Quote Link to comment Share on other sites More sharing options...
MadTechie Posted October 16, 2007 Share Posted October 16, 2007 you could have a it sent 10 per minute on a crown.. (will need to send 6.5 per minute to make the 90 per day) Quote Link to comment Share on other sites More sharing options...
scooter41 Posted October 16, 2007 Author Share Posted October 16, 2007 thats sounds great..... the server techs have just come back with per minute stats too, so that would be handy to do, I didnt realise you could limit the speed of the script..... What code do I need to look up to limit the number per hour? Thanks for your help so far... Quote Link to comment Share on other sites More sharing options...
MadTechie Posted October 16, 2007 Share Posted October 16, 2007 its not limiting the script its a cron.. (looks at last post.. no idea why i said chown).. basically the script will run every 1 minute.. so your need to log the position.. of the emails.. so maybe move the emails to another table (for safety and ease of use) now for the emailing something like select * FROM temptable LIMIT 0,10 email them.. and then delete FROM temptable LIMIT 0,10 this runs every 1 minute (read up on cron) WARNING: this is just VERY QUICK and a basic idea.. THINK about what you want to do.. their probably a much better way the reason for the 2nd table is because of the deletion (of course) but also it won't be updated by other scripts.. Quote Link to comment Share on other sites More sharing options...
scooter41 Posted October 16, 2007 Author Share Posted October 16, 2007 sure, totally aware of cron tasks, I thought there was some special php function to limit the way the script runs......... I've just converted from perl to PHP so still very novice You are right, that idea would potentially work, but does sound a bit 'iffy' I do however like the idea of moving the processed records from a queue to a complete table... at least then it would support resuming if the script falls over! Quote Link to comment Share on other sites More sharing options...
MadTechie Posted October 16, 2007 Share Posted October 16, 2007 true.. or even tagging the records that have been sent, (req. extra field probably date field) Quote Link to comment Share on other sites More sharing options...
prakash Posted October 16, 2007 Share Posted October 16, 2007 how about using usleep(); on every loop or the certain loops exection and letting script run in background from ignore_user_abort(TRUE); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.