View Single Post
Old April 17th, 2006, 4:48 AM   #4 (permalink)
malesca
Registered User
Fresh Surpasser
 
Joined in Jul 2005
3 posts
Gave thanks: 0
Thanked 0 times
Just had to deal with this issue and thought I'd share my solution.

The helpdesk told me the cap is 350 mails per e-mail address, reset at every full hour. My site has a mailing list of currently around 305 users, but sometimes several e-mail announcements will be made in parallell, or one announcement will be made and one new item added, triggering one "mailing list process" each.

My solution, inspired by the one proposed by Kickersny.com above, is simply this:

Store the mail cap in some globally accessible place. I stored "300" to have a margin of error, as anything past the limit will simply be discarded.

Store the number of concurrent mailing list processes in e.g. a database.

When you start to send mails, increase the latter counter by one; when done, decrease it by one.

Between each mail,
PHP Code:
sleep(60*60/$mail_cap*$concurrent_mailings
You would need to retrieve the $concurrent_mailings value at each iteration for this to be accurate. This way, it will send mails at such an interval that it will send $mail_cap mails an hour - and if you spawn more mailing processes, the wait is multiplied so that the number of mails per hour stays the same.

I also use
PHP Code:
set_time_limit(0);  // Don't time out
ignore_user_abort(TRUE);  // Don't stop running script even if window is closed 
to make sure the process isn't cut short.

I checked this with helpdesk and as long as the process isn't very heavy, it's not a problem.
malesca is offline   Reply With Quote