I am trying to create a newsletter that consists of 1 weeks worth of updates to the site. I have created a view of the updates.

In the newsletter template I have added :
<?php echo views_embed_view('the_last_seven_days') ?>

The newsletter template has select lists for tags and Newsletters. I'm not sure what to choose here. I don't really want any particular tag to be used, I just want to send the view.

When I try to send a news letter with None selected for tags I get the error:
1 Newsletter Lists failed to send because no published nodes found for their terms

What do I need to select to send a newsletter that contains only a view?

Many many thanks for you help.

#11 1394346-always_send_newsletter-11.patch2.36 KBParisLiakos
PASSED: [[SimpleTest]]: [MySQL] 166 pass(es). View
#8 always-send.diff3.01 KBalexiosc
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch always-send.diff. Unable to apply patch. See the log in the details link for more information. View
Members fund testing for the Drupal project. Drupal Association Learn more


ParisLiakos’s picture

Title: Newsletter with embedded view failing to send. » Provide option to send a newsletter even if no associated nodes are available
Category: support » feature

hmm interesting.havent though about this usecase.

well if you want your newsletter to be automated, eg being sent on daily/weekly/monthly basis the only workaround for now would be to just select some/or all your taxonomy terms,so that it can find nodes,even though they will not be sent.

i will turn this into a feature request,just to remember that i must expose an option to send the newsletter even when no nodes found.


alohaglide’s picture

Thanks a lot. My use case involves sending a very particular segment of recent activity on the site to someone once a week.

I had tried selection ALL and NONE of the tags.

I just tried selecting 1 tag that was used in the most recent post. It didn't seem to make any difference. Is there something I need to reset to make Newsletter think it hasn't already sent the list?

again, many thanks!

ParisLiakos’s picture

weird..if there is a post that got sent before the last newsletter of this list, it should find it....well a quick and dirty way is to set its last_sent value in the database to NULL,but if it keeps not finding any nodes for these terms,even there are newly created terms that belong there,then we have a bug....and you will have to reset to NULL each time

here is the sql :

UPDATE newsletter_list SET last_sent = NULL WHERE nlid = <the newsletter id of your list here> ;

alohaglide’s picture

Still having the same issue after these steps:

1. set last_sent to NULL, for the newsletter id I am working with
2. under the create/send tab, pressed Send (the newsletter is a manual send)
3. received same error in logs - 1 Newsletter Lists failed to send because no published nodes found for their terms

Been browsing your code looking for things to....adjust. :)

ParisLiakos’s picture

ah nice,didnt know you know coding:)
in that case:

got to line 107 and see if it gets correct the tids of this template..then its the query that runs to find out if there is any node published for these tids.

so right before return if you do dpm($query->execute()) you will see the results and the query that run (you need devel module for dpm function)

alohaglide’s picture

Well, I'm certainly not a super coder, but I can usually figure things out....eventually. :) Question about using dpm() with the devel module (if you don't mind!):

When I add dpm($query->execute()) to, what do I need to run (so to speak) to trigger the display of the message. I have it in there, but I don't ever see the results show up in the message area.

edit: I should say that I have tried the following:

  1. add dpm() code to
  2. reset the last sent to NULL
  3. send newsletter
  4. receive same error and no message with the query.

many many thanks for your help.

ParisLiakos’s picture

hmmm seems dpm wont run since it is inside the cron run,thats why you den get results:)
use die(var_dump($query->execute())); instead,so you get the results no matter what:) ah, you should use <pre> tags to make it more :

echo '<pre>'; die(var_dump($query->execute()));

alexiosc’s picture

3.01 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch always-send.diff. Unable to apply patch. See the log in the details link for more information. View

I needed this today, so I coded a patch. It includes a new database column and a form element (plus, of course, the requisite check in the code). Here it is. It's against version 7.x-1.0-beta6, though.

ParisLiakos’s picture

Status: Active » Needs work

thanks for the patch!

but why this?:

-    WHERE send_again = CURDATE()
+    WHERE send_again <= CURDATE()
alexiosc’s picture

I just saw this now (ironically, while debugging a newsletter issue for the same client I wrote the patch for).

Here's the rationale for the <= CURDATE() change as far as I remember it from February: in the original code, if send_again comes and goes without (for whatever reason) cron running (e.g. server downtime, migration, messed up system time, etc), the newsletter isn't sent at all and you have to wait till the next period. With the <= in place, if send_again is in the past, the newsletter will be sent. Under normal circumstances, send_again is either today or in the future, so this doesn't break anything.

ParisLiakos’s picture

Status: Needs work » Needs review
2.36 KB
PASSED: [[SimpleTest]]: [MySQL] 166 pass(es). View

Uh sorry...i forgot about this issue..and tbh i found out myself that <= is needed...
i dont think this is complete yet..we need to get views to know about these field as well...setting it to needs review to trigger the tests

danohnesorg’s picture

Also the default value in this form is wrong:

--- a/includes/
+++ b/includes/
@@ -745,6 +745,11 @@ function newsletter_list_edit($form, &$form_state, $list) {
     '#default_value' => check_plain($list->send_rate),
     '#title' => t('Send rate'),
+  $form['always_send'] = array(
+    '#type' => 'checkbox',
+    '#default_value' => FALSE,
+    '#title' => t('Send newsletter even if there are no nodes to list.'),
+  );

you have to use '#default_value' => check_plain($list->always_send),

Patricia_W’s picture

I added this comment to another thread (is #12 the solution?):
I manually applied the patch to the beta 9 code. It appears to be working. Always send works correctly but when I edit the list (after previously checking the box) the checkbox isn't checked anymore. With my very limited PHP knowledge I don't know how to get this to work.

doliveros’s picture

Patricia, that's what #12 meant. To keep the checkbox checked, you need to change this line: //'#default_value' => FALSE,// to this line: //'#default_value' => check_plain($list->always_send),//

#11 seems to work correctly. Should be commited IMO.

ssoulless’s picture

Issue summary: View changes
Priority: Normal » Major
Status: Needs review » Reviewed & tested by the community

Reviewed, This module needs an option of send custom content without the necesity of look for taxonomies of nodes. So I think this is a priority.

ParisLiakos’s picture

Status: Reviewed & tested by the community » Needs work

patch does not apply and #12 needs to be fixed

sk2013’s picture

Any update on this issue please?


dat deaf drupaler’s picture

Could really use this patch.. Im using the views also.

Paulmicha’s picture

On this issue's subject, how about letting other modules provide their own classes (i.e. extending NewsletterBasic, like NewsletterAutomated does) ?

For ex. by introducing a new hook in newsletter.module - function newsletter_create(), like :

 * Instantiates a new Newsletter class
 * according to
 * @return
 *   A newsletter object.
function newsletter_create($nlid = NULL, $ntid = NULL, $nnid = NULL) {
  // Allow other modules to implement custom newsletter classes.
  $custom_candidates = array();
  foreach (module_implements('newsletter_create') as $module) {
    $n = module_invoke($module, 'newsletter_create', $nlid, $ntid, $nnid);
    if (!empty($n)) {
      $custom_candidates[] = $n;
  // If there are several candidate implementations, the last takes priority.
  if (!empty($custom_candidates)) {
    $newsletter = array_pop($custom_candidates);
  elseif (isset($ntid)) {
    $newsletter = new NewsletterCustom($nlid, $ntid, $nnid);
  elseif (isset($nlid) && !isset($ntid)) {
    $newsletter = new NewsletterAutomated($nlid);
  else {
    $newsletter = new NewsletterBasic();
  return (object) $newsletter;

Then in another module :

 * Implements hook_newsletter_create().
function mycustmod_newsletter_create($nlid, $ntid, $nnid) {
  // Here could go some (optional) selection code, then :
  return new FooNewsletterAutomated($nlid);

class FooNewsletterAutomated extends NewsletterBasic {
  // ex: Adapt class NewsletterAutomated contents to your needs.