How to reduce page load times by sending emails via cron, rather on page submission

A frequent problem we see at client sites is when they click submit on a page, whether it is a creation of a node or a comment, and then the site does not come back for several minutes.

The problem sometimes is due to connections to third party servers for Web 2.0 services, but can also be due to modules that send emails. For example, Organic Groups can be configured to send emails to all group members when a new post is submitted, or when someone comments on an article, ...etc.

So far, each module had to implement its own solution to this issue. For example, organic groups solves this problem by relying on the excellent job queue module. The subscriptions module has a settings for sending notifications via cron rather than at node/comment submission time.

Up until now, there was no generic way to make all emails sent from Drupal be sent when cron runs.

We wrote the queue mail module to address this requirement. It intercepts emails send from Drupal, and then uses the job queue module for the actual sending.

This way, any module that sends emails is prevented from slowing down page loads for end users.

Big thanks to all the people

Big thanks to all the people from 2bits for yet another important release! I'm off to begin testing...

thank you!

this is EXACTLY what i have been waiting for - without it, any sort of notifications module brings a site to crawl...the node has to check for all subscriptions,and process for all...you have saved the day!

this should be in core imho, as message handling and cron have already found most of their way in there...

Thanks but no ...

Thanks, but I disagree that it should be in core.

Core is doing exactly what it should: provide extensible and flexible APIs for other modules to use.

By having those APIs, people can extend their sites any way they want, which may not be the same way that the next person wants.

So, our module uses the API from core for email, and the API for job_queue. Other modules may or may not want to do it in other ways.

Having it in core will just make core bigger, and force one way to do things.

We avoid that by having lean APIs only.
--
2bits -- Drupal consulting