How to send emails to 20,000 + registered members efficiently? I have a Drupal 7 site with about 20,000 members.  Sometimes I need to email them all at once.  Thus far, I have been adding a rules component (Condition: Make sure user has not opted out of emails, Action: Send email, translated as appropriate for each language) and then used VBO and a view to select all the users on the site.

Unfortunately, with such a large number of users, even when VBO is queued to send emails 10 at a time the batch often encounters some error every few thousand users, so I need to find which user was last e-mailed when the batch error occurred and restart the batch manually.

Is there a more robust (i.e., automatic way that will not break and require manual intervention on my part) to email all the user accounts on the site when the number of users is large?
Below is a summary of how you can improve what you already have in place ...

Part 1 - Use a flag to keep track of the progress


Introduce an additional flag to allow "flagging" of some new or updated "entity" (eg "nodes") by all users "which you need to email all at once" (as in your question). Let's assume you label that flag as "eMail notification outstanding" (to indicate that something still needs to happen to send that eMail later on).

This of course assumes your eMails are to be triggered by such new or updated entities. But if you don't have such entities (= you have another reason to send such eMails), you could introduce a dedicated content type and use it as a kind of eMail template (with fields up to your own imagination). And each time you have a new eMail to be delivered, just create an appropriate node (of this dedicated content type) for it.
Create a rule to flag the newly saved (or updated) content, using the new flag (from step 1) for each of the users you already have in your existing "a view to select all the users on the site".
Use the Views and the Views bulk operations (VBO) modules to create a VBO list of all flagged nodes (flagged by the new flag in step 1), sorted by flagging date (oldest first), and limit the results to the first X users only (pick a value for X that fits your needs).
Create a new Rules Component that "loads the VBO list" (from step 3) and add a loop to that rule to perform these Rules Actions:


eMail each of the users in that VBO list (you can probably reuse the Rule to "send an eMail" that you already have).
unflag (using flag from step 1) the node (for the user for which you just produced an eMail). This to indicate that the eMail notification was completed (no longer outstanding).


In that same rule, as the very last Rules Action, add an action to reschedule the execution of the same rule within Y minutes or hours  (pick a value for Y that fits your needs).
Use the Rules UI to manually trigger the very first execution of that self-rescheduling Rules Component (from step 4.).


Using the above approach, every Y minutes (or hours), Rules will eMail X users "as requested".

Part 2 - Recovering from an error

Sooner or later, Mr. Murphy will come along again, and it might cause some error again (eg after a few thousand users). If that happens, all that's needed is to repeat Step 5 ... And even if you didn't realize the error at first (only after X hours or days or so), all that's needed is to repeat step 5 as soon as the error got noticed.