Jump to content

Archived

This topic is now archived and is closed to further replies.

stevesmename

Query only Certain Information

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 100
Ok.

I then did between 101 and 200
Problem, 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.

Share this post


Link to post
Share on other sites
[code]... your script ...

$sent++; // count # messages sent since we paused
if ($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]

Share this post


Link to post
Share on other sites
I'm Currently Running the Newsletter Script Now, Sending to 16,160 Subscribers, and it's DOING FABOLOUS!!! Thank you AndyB

The smallest addition of sleep(); helped my script immensly!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.