Jump to content

Loop Delay


Anon-e-mouse

Recommended Posts

Evening,

 

In simple, I have a script that loops through members when submitted and sends them a confirmation email for an event. However I don't want to send 200 emails one after the other because Google would get very upset.

 

Thus! I attempted to use sleep() but that didn't function as I thought it would inside the loop. Causing the entire thing to wait for the amount of seconds times the result set. So. Whats would you suggest?

 

Thanks.

Link to comment
Share on other sites

Make sure your host/ISP knows you plan on doing this, and that the emails are solicited. Your host may even have something pre-installed to help you with this.

 

I'd approach this with CRON. Have a database table called `emails` or something, using a unique ID. Store the email's body in there. Create another table called `email_que` or something. Store the user's ID (to link back to their email) and the email's ID.

You'd then create a PHP script that CRON would call every 30mins/hour/whatever. This script would grab the oldest 50/100/500/etc. rows in `email_que` and perform the mail function, removing the rows after completion.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.