[wp-hackers] How to throttle emails on hosts with email sending limits?
william.canino at googlemail.com
Thu Oct 15 00:18:27 UTC 2009
I definitely ought to figure this out soon.
I installed WordPress on Dreamhost today. DH has a "100 recipients
per hour" limit.
Even without plugins, if the blog gets 101 comments in one hour,
wordpress's "new comment" notification emails to the post authors will
hit the limit.
Therefore I will have to override wp_mail() itself.
The new wp_mail() somehow needs to remember how many recipients have
been sent in the last 3600 seconds. Three ways to do this:
1. I have it accumulate emails unto a wp_option setting and with
wp_schedule_event send just enough during the top of every hour. On
the average they get it half an hour late.
2. I store each email as a record in a table, and record the sent
times, all within a SQL SELECT-UPDATE-COMMIT transaction. Thankfully,
the emails don't have 2Mb attachments!
3. A better option?
Sorry if ask again, guys, has anyone integrated mail queuing code to WordPress?
2009/10/9 Art Delano <ajd at cloudiness.com>:
> Would it be possible to make it work like this?
> 1. Check if anything needs sending
> 2. Concatenates all pending emails into a digested message
> This would reduce the number of mails sent to one per time window.
> On Oct 9, 2009, at 4:31 PM, Otto wrote:
>> Looking at the plugin, it appears to hook to comment_post to send the
>> notification emails.
>> I'd rework it a bit. Change the comment_post hook to run a new
>> function which does a wp_schedule_event to a new action (maybe
>> stc_send_notifications?). Then hook that to a new function which does
>> the following:
>> 1. checks to see if anything needs sending still
>> 2. sends emails up to limit
>> 3. if still some left, do another wp_schedule_event to rerun at some
>> future period of time.
>> Sent from Memphis, TN, United States
>> On Fri, Oct 9, 2009 at 2:39 PM, William Canino
>> <william.canino at googlemail.com> wrote:
>>> One of my blogs is on 000webhost and I use Mark Jaquith's "Subscribe
>>> to Comments" plugin among others and its hosting account was suspended
>>> one night when a discussion, well, got out of hand.
>>> 000webhost's email sending limit is 'No more than 30 emails per 5
>>> minutes and no more than 100 emails per hour.'
>>> 000webhost's PHP config doesn't support SSL/TLS so I can't send via
>>> Gmail. In any case, Gmail also has a limit of "100 people at a time".
>>> So as a stopgap I added a "ORDER BY comment_date DESC LIMIT 28" clause
>>> to Jaquith's plugin and crossed my fingers.
>>> Before I go study how to add the Throttle plugin to Swift Mailer and
>>> use Swift as a wp_mail() replacement, I thought of coming here to ask
>>> if someone has already made or begun a throttling solution or plugin.
>>> A plugin like this may be interesting to write for public release
>>> because, for example, in this case, 000webhost has two limits and
>>> gmail has another kind of limit.
>>> P.S. It amuses me how often various plugins just "do their own thing"
>>> to send their mail.
>>> wp-hackers mailing list
>>> wp-hackers at lists.automattic.com
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
More information about the wp-hackers