Sending Recurring Emails to Thousands, using Simplenews as a Backend

I recently had a rather unique project requirement on one of my sites: I needed to send out a weekly email to hundreds (soon to be thousands) of site users, with the same template each week, but with the latest data from the website.

Basically, what I wanted to do was create a View on my site of the latest 10-12 items, and have that view be sent out to everyone (along with the views header/footer) in HTML (with a plain text alternative, of course), but I didn't want to have to create a new newsletter by hand each week to do this (this is something at which the Simplenews module excels... minus the automation).

After debating over whether I should write my own module to do the dirty work of sending out batches of emails, using modules like Views Send along with Rules and Views Bulk Operations, and some other crazy ideas, I finally found a potent combination for sending out automated weekly newsletters in a highly performant and optimal way, using the following modules:

  • Simplenews (for queuing/sending emails, managing subscriptions)
  • Rules (for scheduling the newsletters)
  • Elysia Cron (for easy cron scheduling and performance)
  • Views (to build the body of the newsletter)
  • Mime Mail (to send HTML emails, and to be able to easily have a custom email-friendly stylesheet)

Drupal Simplenews: Automatically Subscribe New Users to a Newsletter

One of the sites I am setting up requires that all users be subscribed to a certain newsletter (or maybe two, depending on who they are) via Simplenews when they create their accounts (actually, their accounts are automatically created via LDAP... but that's another story).

Looking around, I found this post explaining how you might be able to auto-subscribe new users, and it led me to look up Simplenews' simplenews_subscribe_user() function.

Basically, you can add a line like the following in your custom module's hook_user() function, on the 'insert' $op (for Drupal 6):