Many web-hosts have limits on the number of emails that may be sent, before the site is considered spamming. For example 200/hour, or similar. It would be good if this module could support such a limit, and send queued emails over as long a period of time as required...

Comments

lyricnz’s picture

StatusFileSize
new4.68 KB

Here is a quick patch to queue_mail that creates a limit on the number of emails that will be queued at any one time, and puts any extras into a separate queue. Then a new job is added to the job queue, that pulls items from this separate queue and submits them to the real queue.

Notes:
- the limit is configured in at /admin/settings/queue_mail - this is the limit *per cron run* (usually hourly)
- you may want to configure the priority of sending of individual emails to be higher (lower number) than the unbatching of mails over the limit - at /admin/settings/job_queue
- if mails are being queued *while* cron is running, you may get mails sent out-of-order

lyricnz’s picture

Status: Active » Needs review
StatusFileSize
new4.54 KB

Update patch to use the job_queue function, rather than description, to find our jobs.

lyricnz’s picture

StatusFileSize
new4.54 KB

Update patch to just add enough mails to refill the queue to the specified limit.

mattcasey’s picture

Thanks lyricnz, I am setting up a new site and want this feature. I've manually updated my module and will report back when I successfully use it.

Slightly related: I am using Simplenews, which allows me to throttle per cron run. Does that mean I don't need to use Queue Mail and Job Queue?

webwriter’s picture

I have installed the patch and am waiting for my next Sunmailer run to go out Wednesday to see if it works properly, but it looks good so far. Thank you very much for this functionality.

Freso’s picture

Status: Needs review » Needs work

Not tested, but just from a quick glance, I can tell that variable_del('queue_mail_limit'); is missing from the uninstall function.

Also, it doesn't look like mails sends immediately (as opposed to being queued) are subtracted from the queue limit. If the webhost indeed does have an hourly (or otherwise) limit, setting queue_limit to that may end up causing some mail to fail, as immediately sent mail will make it cross that threshold. Of course you could guess/estimate a probable margin, but you may still run into problems with just that odd day where a lot of users have lost their passwords - plus, sending a mail to hundreds of users at a rate of 93-95 users/hour is considerably faster than at 70/users per hour (or however low one has decided to set it). All of this is, though, probably feature creep and should be added as a patch of its own once this gets in (if ever...).

scottcheek’s picture

Any chance this functionality could be ported to D7?

lyricnz’s picture

The maintainer never bothered to apply this patch in over 2 years, so I'm not inclined to spend time porting the patch myself.

steven jones’s picture

Just a quick note (from the D7 branch maintainer):

As we basically just put things in to a Drupal queue now, it would make much more sense to have something that can limit the rate at which things are removed from any queue, and so such a feature wouldn't get into the D7 branch, so there's not any point in porting. Sorry!

sinn’s picture

Issue summary: View changes
Status: Needs work » Closed (won't fix)