stevesmename Posted April 14, 2006 Share Posted April 14, 2006 I have a table with 20,000+ Email Addresses, I run a php script which is suppose to email all the Email Addresses (LEGITLY - Am Not a spammer). Sometimes the script seems to stop and never email them all. So my proposed solution is to Divide up the labor for the script.I wish to have a sql command for MSACCESS Database so I can select the First 1000 emails, send them out. Then wait 20 minutes - and send out 1001 - 2000 emails. Then wait 20 minutes - and send out 2001 - 3000 emails.and repeat.This will be easier on the Company's Email Server, plus I can verify all the emails get sent. Hope this isn't to difficult, Currently the database is setup with the Email Field as the Primary Key so I don't have any duplicates, and there is no numbering system. But I wouldn't mind adding one with an AutoNumber format so I can keep track who I emailed and who I haven't yet.I don't mind changing the script every 20 minutes by hand. Hope that makes sense. Quote Link to comment Share on other sites More sharing options...
AV1611 Posted April 14, 2006 Share Posted April 14, 2006 First, you can run PHP from the commandline from windows or from linux, so I would suggest you create a series of scripts... email1.php, email2.php, etc... using LIMIT and then set them up as scheduled tasks to run from the command line. now you can control the time and size of each post.I have some large scripts that draw from multiple databases then create reports off of it. I run the large script as a nightly scheduled event, then let the clients run the reports from it during the day... runs great that way... Quote Link to comment Share on other sites More sharing options...
AndyB Posted April 14, 2006 Share Posted April 14, 2006 It's likely that your php script is fine, but the mailserver is what chokes.I've run large mailings from a single script my using a trivial counter and then using the sleep() function [to give the mailserver a chance to clear itself] every 50 emails. Quote Link to comment Share on other sites More sharing options...
stevesmename Posted April 14, 2006 Author Share Posted April 14, 2006 Thank you both for your fast reply!I originally intended to have the script run via Command Line - but I wanted to view the Emails it sent too so I did not send duplicates, and made sure the script worked okay. I still enjoy that feature, so I don't think I would want to move on to a command line just yet. I started to do some research and testing with a small amount of emails [code] $sql= "SELECT * FROM $table WHERE ($newsletter = Yes) AND ID between 1 and 10";[/code]It seemed okay, I then did between 11 and 30 Ok.I then did between 30 and 100Ok.I then did between 101 and 200Problem, I noticed an email got sent twice and maybe more times.Which makes no sense, the Column ID is an AutoNumber generated auotmatically and Indexed (no duplicates). But it displayed "Emailed 101 of 200: ckay@...something.com" I did a search for 101 in the ID Column and found that it should of been BJAY..@aol.com This thing is driving me nuts.AndyB: You mentioned something with the Sleep() Command, this may help a lot for my script.I think if I change the code back to[code] $sql= "SELECT * FROM $table WHERE ($newsletter = Yes)";[/code]Which Sends email to eveyone at once who wish for the certain newsletter.I already have a counter script in place.Is there some more info you could give me with the Sleep() function? Thanks a lot to the both of you. Quote Link to comment Share on other sites More sharing options...
AndyB Posted April 14, 2006 Share Posted April 14, 2006 [code]... your script ...$sent++; // count # messages sent since we pausedif ($sent==50) { $sent = 0; // reset trivial counter sleeep(1); // pause script for 1 second}... your script continues ... [/code][a href=\"http://ca.php.net/manual/en/function.sleep.php\" target=\"_blank\"]sleep() function[/a] Quote Link to comment Share on other sites More sharing options...
stevesmename Posted April 14, 2006 Author Share Posted April 14, 2006 Thanks! Quote Link to comment Share on other sites More sharing options...
stevesmename Posted April 14, 2006 Author Share Posted April 14, 2006 I'm Currently Running the Newsletter Script Now, Sending to 16,160 Subscribers, and it's DOING FABOLOUS!!! Thank you AndyBThe smallest addition of sleep(); helped my script immensly! 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.