1

enter image description here

In my content I have one date field which is entered by the author, who fills that as future estimate date like tomorrow or after 1 month. Depending on that estimated date, on that day mail should trigger.

Example: my date field is "weaning date" which the author will fill at as after one month on that day should trigger a mail.

  • Have you checked rules scheduler? drupalize.me/videos/introducing-rules-scheduler?p=1157 and youtube.com/watch?v=OgRKLXRbPX8 – arpitr Sep 17 '15 at 5:36
  • @ arpitr- Thanks for your response i will check with this videos and come back to you. – DINE Sep 17 '15 at 5:41
  • @ arpitr -i have gone through this video but i am not getting how to do this,by using rules scheduler, mentioning the date value when we need to trigger exactly after one day or after one week. But my question is what the author will give the date in field its may be today other wise tomorrow or after next year its not a particular date whatever the date given by author in date field on that day mail should trigger heip me on this i am very helpful......... – DINE Sep 17 '15 at 6:00
  • so if he selects sept 25, 2015 then he gets an email on sep 25 correct? – No Sssweat Sep 17 '15 at 7:23
  • @ NoSssweat- yep,should trigger a mail on that date. – kashish Sep 17 '15 at 7:25
1

You might use the Rules Scheduler module (included with Rules) for this. The following tutorial explains a case similar to yours: http://www.webwash.net/tutorials/how-send-follow-emails-using-rules-scheduler-drupal-7

In short, you would need to:

  • create a "send email" component that sends an email with a user as parameter
  • create a rule triggered when a node of your content type is modified
  • set the action for that rule to an "scheduled component evaluation" that uses the "send email" component you created.
  • in the "scheduled evaluation date" of the action you need to press the "switch to data selection" button, and then to select the date field of your node from the dropdown menu.

Note that the scheduled component evaluation is triggered by cron. You need to make sure that cron is configured correctly in your site.

Hope that helps,

  • thanks for your response.date field of my node means .can i give like this "field-warning-date"or[node:field-warning-date]. – kashish Sep 17 '15 at 8:38
  • @ dinopmic- one more quick question, schedule evaluation date means ?actually i will mention +week instead of that you are saying to use node field? – kashish Sep 17 '15 at 8:43
  • @kashish - Yes, you need to switch to "data selection mode" in the "scheduled evaluation date", in order to be able to select the field. By default it is "direct input". I have updated my answer. – dinopmi Sep 17 '15 at 9:27
0

Use the Rules module together with Rules Scheduler (a sub-module of it) for sending such eMails, as explained in the steps below.

Step 1: Create a field to store the "weaning" date

Assume your weaning date field has a machine name (say) field_weaning_date, for which only 1 date is allowed.

Step 2: Create a Rules "Component"

Here is the Rules Component to be created, in Rules export format (just import it in your own environment via copy-paste):

{ "rules_send_email_notification" : {
    "LABEL" : "Send eMail notification",
    "PLUGIN" : "action set",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "user_to_notify" : { "label" : "User to be notified", "type" : "user" } },
    "ACTION SET" : [
      { "mail" : {
          "to" : [ "user-to-notify:mail" ],
          "subject" : "Reminder you requested",
          "message" : "This is a reminder that you asked for ...",
          "from" : "[site:mail]",
          "language" : [ "" ]
        }
      }
    ]
  }
}

Obviously, the Subject and Content of the eMail may need review / tuning, while you might also want to use some other From eMail ID.

Step 3: Create a "Rule" using the Rules Component

Here is the Rule to be created, in Rules export format (just import it in your own environment via copy-paste):

{ "rules_send_email_on_a_scheduled_date" : {
    "LABEL" : "Send eMail on a scheduled date",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "rules_scheduler" ],
    "ON" : { "node_presave" : [] },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_weaning_date" } }
    ],
    "DO" : [
      { "schedule_delete" : { "component" : "rules_send_email_notification", "task" : "[node:nid]" } },
      { "schedule" : {
          "component" : "rules_send_email_notification",
          "date" : [ "node:field-weaning-date" ],
          "identifier" : "[node:nid]",
          "param_user_to_notify" : [ "node:author" ]
        }
      }
    ]
  }
}

The above rule refers to the Rules Component from the previous step.

The schedule_delete that is part of this rule is to ensure that previously "scheduled" reminders will get removed when updating the data field (so that it only triggers 1 reminder, and with the most recently entered date).

Attention: as per your specs in your question, if anybody different from the "author" ever updates that weaning date, the effect of doing so will be that:

  1. no eMail will be send on the previously requested "weaning date" (if that is not what you want, then remove the schedule_delete part in the rules action in Step 3).
  2. the "author" will receive another eMail, on the updated weaning date (if that is not what you want, then add a rules condition in Step 3 to verify that the editor's userid matches the author's userid).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.