Jump to content

Recommended Posts

Hey,

 

I have a client who wants to be able to send newsletters.

Due to hosting policy, i can only send 1 email every 6 seconds - so i need to throttle it.

 

IDEALLY, i'd want a cron job running every 3 hours that checks if a newsletter's waiting to be sent, if there is one, it sets up another cron job which runs every 6 seconds. This then checks for the next recipient, sends mail.... checks... sends... etc.. etc...

When it runs out of recipients, it deletes the 6 second cron job. The 3 hour one still runs.

 

However i don't think this is possible?

 

So i need a different way of doing it...

I can think of 2 ways;

 

1) Let the cron job run every 6 seconds... CONSTANTLY. Which is very intensive IMO.

 

2) When my client clicks "send" on the newsletter form, it makes a pop up window, this then refreshes (with JS) every 6 seconds, at which point it gets the next recipient and sends another email etc... etc...

When it runs out of recipients, it auto-closes or shows a 'complete' message.

 

The second way of doing it means i can display a progress bar with '34/500 newsletters sent' messages in the pop-up window.

A cron job could run every 6 hours to check and see if there are any more recipients to send to and if so, send an email (with a link to the pop-up sender) to my client (just in case he closed the pop-up before all emails were sent).

 

 

Are these the only ways of doing it or does anyone else have any ideas?

 

 

Thanks very much,

 

Chris

Link to comment
https://forums.phpfreaks.com/topic/85014-custom-php-newsletter-throttler/
Share on other sites

question... does your host not want you to "open and close an SMTP socket for each email" unless six seconds go by? If that is the case, then you should use PEAR::Mail, which opens one socket for lots of mail (used for things such as mailing lists).

 

Otherwise talk to the host, and see if they can increase your mail output to increase the number you can send.

 

OR

 

create a cron job that runs every hour or so use sleep(6) in your php to stop php for 6 seconds (and use a loop to do this).

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.