Last updated 20 September 2013. Created on 20 September 2013.
Edited by Paul Broon. Log in to edit this page.

What's this about?

Most of the projects I am working on involve creating a website (obviously). In most cases, the project team also requires an internal area (which might be another tutorial in the future). Out of that structure came the need to have a weekly digest of recent activities in that internal area. The users do not want to login every day to check for new or updated content and neither did they want to receive an email (via rules) each time new content or comment is added.

What's the current situation?

There are quite some modules which aim to achieve a function similar to a digest. Notifications apparently had this functionality in D6 version, but 7.x is in dev (without any change since summer 2012). I was able to get something working, using Notifiations 7.x-1.x-dev, Job Scheduler 7.x-2.0-alpha3 and Messaging 7.x-1.x-dev. However, on the specified date (or time) it wouldn't send out a single email (digest functionality) but one mail for each new content or comment.

Apparently, there's another system based on Message Notify used in Drupal Commons. You can read their blog post about that approach. Also, a bunch of developers and sponsors are working on a general approach to create digests. See the corresponding issue for more details.

Why this approach?

While the general solution seeked on the issue mentioned above is quite interesting and promising (I am trying to closely follow the development), I need a solution rather now and fairly simple as I plan to integrate it into various project websites. So I went over this problem of how I could achieve anything like a weekly digest by using only contributed modules and not writing a single line of code. As I found several requests for something like that, I thought this may help quite some other site builders and here it is.

How does it work?

My approach depends on having a designated newsletter, which is sent out on a regular basis (weekly in this example). The newsletter content is mainly a view containing contents and comments since the last newsletter. That's actually all there is to it.


This setup was developed and tested using the following core and module versions.

Drupal Core 7.23
Views 7.x-3.7
for creating lists of new/updated nodes/comments
Viewfield 7.x-2.0
for embedding a view inside a node (as a field)
Views Field View 7.x-1.1
for embedding a view inside another view (Format > Show: Fields)
Simplenews 7.x-1.0
for creating a digest newsletter
Simplenews Scheduler 7.x-1.0-beta2
for sending that newsletter on a regular basis

Note: there are other modules required by these, e.g. CTools and Date. Also, Simplenews Scheduler requires at least PHP 5.3 to work.

Install and enable the modules above as normal. With Date module enabled you will need to set your time(zone) settings afterwards.

Setup & Configuration

By activating Simplenews a new default newsletter category is created. This may be used for the standard newsletter so I just created a new one: "Weekly Digest" at /admin/config/services/simplenews/add.

Next, we create two new views, one containing all nodes (examples are restricted to type "Basic Page") that have been created, updated or commented on during the last 7 days. The second view contains all comments for a node (passed by argument) from the last week. To keep this article short and save you same time, I have exported the views, find them attached to this page.

Now it is time to extend the Simplenews Newsletter content type. At /admin/structure/types/manage/simplenews/fields add a new field of type "Views". You can stick with the pre-defined default values.

Time to create the actual newsletter. Do that by visiting /node/add/simplenews and select "weekly_nodes - Page" in the newly added field. Also don't forget to select your new newsletter category. Give the node a descriptive title, explaining what is going to be digested. For my projects I am using "Internal Area" as only content types which are used internally are listed in my views. You may also add a description into the body field. Save the node and visit the newsletter tab of your new node.

There, you select the option "Send newsletter according to schedule". Below, a fieldset appears where you can set all relevant data like when it shall start being send and which interval is to be used (week, frequency 1). For title pattern I often use something like [node:title] - week [current-date:custom:W]. My Simplenews category itself is set to create the Email subject [[simplenews-category:name]] [node:title]. That way, the final subject will be something like [Weekly Digest] Internal Area - week 38 ([Newsletter category] Node title - week #). Submit your options and you are pretty much done.

Of course, you can now go ahead and setup Simplenews for example to send HTML mails, create templates for that or adjust the two new views to contain more or less information.

Looking for support? Visit the forums, or join #drupal-support in IRC.


Matt B’s picture

Hi, thanks for this. I've created the newsletter with a views field. Viewing the newsletter on the website is fine, but the email I receive does not include the views data, only a link back to the newsletter on the website. How do I get the views data displayed in the email?
I've tried this with the viewsfield module, insert view module and view reference module. All of which output the views on the web page, but not in the email.

Paul Broon’s picture

I am still running the same setup in a selection of websites and until now, I haven't had any errors.

Here's the updated modules list (changes in bold):
Drupal Core 7.34
Views 7.x-3.10

Viewfield 7.x-2.0
Views Field View 7.x-1.1
Simplenews 7.x-1.1
Simplenews Scheduler 7.x-1.0-beta2

So I am definitely using Viewfield module to insert the view into the Simplenews content type. That way, it's actually part of the node and is present in the weekly mail (at least for my sites).

Matt B’s picture

It looks like its a permissions thing. I've created a site where certain nodes are restricted to authenticated users. From the testing I've done I can see this method will only display nodes that the anonymous user can see.

FrancoisL’s picture

I'm getting the same conclusion. Is there another way to solve this? did you found something?

Thanks in advance.


Paul Broon’s picture

In general, Simplenews doesn't support any node access modules, thus you can send out a Simplenews node via email even if the node is not accessible directly on the website. However, Views will check for permissions and therefore the embedded view will only show content and comments that are publicly accessible.

For now, I don't see a workaround by just using contrib modules. The only way I can think of, would be to (programmatically) create a node from a view's content. Then, the content would be part of the node and thus available to be sent.

FrancoisL’s picture

Hello I found this thread:

were they explain that we can use a Views option:

Edit the view, and in Advanced find Query settings, then you'll find the option to: 'Disable SQL rewriting'.

This work fine for me. Hope this can help others :)

irinaz’s picture

Hi, did you ever use Mandrill to manage these weekly emails?

Paul Broon’s picture

The short answer is no.
This weekly digest is just a small part of a project management tool, I have been developing throughout my recent projects. For the digest, simplenews has been sufficient together with Drupal's (PHP) mail function. However, one of the recent feature requests was to integrate some kind of mailing list. So I am looking into the OG mailing list modules. There are two of them (og_mailinglist and og_mailing_list). The latter only works with GMail accounts so far, but the first one has an integration for Mailgun which is a pretty similar service to Mandrill.
So the long answer is, I am currently focussing on Mailgun (due to the module's support). If the module maintainer plans to support Mandrill as well, this might be an option.

An alternative might be the SMTP module. You can integrate any 3rd party mail service you want. So, you should be able to use Mandrill for all your mails.