How to send a mail to a user with views rules when a date is passed? I have created a date field for all users (in Drupal 7). This date is the end of the user's subscription. When the date of this field is passed, I want to send a mail to the user to tell him he can subscribe again (to access our website).

So, I have created a view with a display rules (with module views rules). I have listed all users who have the field date not empty and filter to have only date passed. I have 2 fields in this view (user name and date). I have edited field info and enable my 2 fields (Data type : user and data type : date) :



After, I have created a rule wich react on the event "Cron maintenance tasks are performed" and created a view loop on the display rules of my view. In the loop i have added 2 actions : change the date value to exit the user from the view, and send a mail to this user :



When I Launch the cron, nothing happen. The date is not changed, and the mail is not send. I don't know what configuration I have forgot. Do you have an idea please ?

Thank you for help me.

My rule in export format:

{ "rules_relance_e_mail" : {
"LABEL" : "Relance e-mail",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"ON" : { "cron" : [] },
"DO" : [
  { "VIEW LOOP" : {
      "VIEW" : "dates_de_relances",
      "DISPLAY" : "views_rules_1",
      "ROW VARIABLES" : {
        "name" : { "name" : "Nom" },
        "field_date_de_relance" : { "field_date_de_relance" : "Date de relance" }
      },
      "DO" : [
        { "data_set" : { "data" : [ "field-date-de-relance" ], "value" : "+1 year" } },
        { "mail" : {
            "to" : [ "name:mail" ],
            "subject" : "Test relance",
            "message" : "Test mail",
            "language" : [ "name:language" ]
          }
        }
      ]
    }
   }
  ]
 }
}
Part 1: Sending an eMail

Your view needs refinement ...You seem to have 1 Views result (row) for each user to be eMailed, which is OK. But that view must have fields (columns) for each of the fields that you want to use in your Rules Action to create your eMail. So the [name:mail] and [name:language] in your Rules Action should be replaced by some column in your view to make those available. For that you might have to also add a "relationship" in your view to the "user object" (so that eg the eMail ID becomes available).

Have a look at these answers for some more details:


How to make fields available in Rules using the Views Rules module?
How to use Rules to send an E-mail after saving a new comment, to users who checked a boolean in their profile?


Part 2: Saving the changed date

You may have to add an extra Rules Action to "save an entity", because you need to remind the Rules module to also save the date you've updated.