0

How to send an email once in every 6 months at 12:00 am for a date field about user renewal which is there in user profile using the Rules module?

Its mail should send in cyclic form every once in 6 months to notify user, repeating the mail once in 6 months.

So far I followed the tutorial "How to Send Follow-Up Emails Using Rules Scheduler in Drupal 7", and I have created a Rules Component, I then created a Rule like so:

  • Rules Event: After saving a new user account
  • Rules Conditions: None
  • Rules Action: schedule the Rules component (which I created before), with Scheduled evaluation date:+6 month and User > Data Selector: account.

So this is what I have done so far and this email I want to send every 6 months once repeatedly same email

  • sorry, I don't have time for a full answer. I'll point you in the right direction. Google "rules scheduler" – No Sssweat Sep 9 '15 at 12:15
  • @sssweat: i understand, well i have already installed the rules and created component and also set the rule but i dont know what exactly to do because by seeing many of the tutorial m getting confused and now finally m blank not getting what to do.:(:(:(:(:(:( – kashish Sep 9 '15 at 12:21
  • 4
    possible duplicate of Send user a reminder email after x-number of days if Profile2 field is empty and user has specific role - I know it's not exactly the same question but it seems answer there would fit here as well. – Mołot Sep 9 '15 at 12:49
  • @molot: my requirement is to send every 6 month once and its just like cycle form it should notify user every 6 month once, am not able to find the solution for this, i am in hard time. – kashish Sep 9 '15 at 12:59
  • @kashish: It would be better, if you describe, what you have done so far and what doesn't work. You said, that you tried to learn from many tutorials - so do not ask for another one. – Miloš Kroulík Sep 9 '15 at 14:38
0

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

Step 1: Create a field to store the "next renewal" date

Add a field to the "user" entity with machine name (say) field_next_renewal. Allow only 1 date (to store the "next" renewal date).

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 about your next renewal",
          "message" : "This is a reminder about your next renewal on [user-to-notify:field_next_renewal] ...",
          "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_email_user_every_6_months" : {
    "LABEL" : "eMail user every 6 months",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "rules_scheduler" ],
    "ON" : { "user_insert" : [] },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "account" ], "field" : "field_next_renewal" } }
    ],
    "DO" : [
      { "data_set" : { "data" : [ "account:field-next-renewal" ], "value" : "+6 month" } },
      { "schedule" : {
          "component" : "rules_send_email_notification",
          "date" : {
            "select" : "account:field-next-renewal",
            "date_offset" : { "value" : 15552000 }
          },
          "identifier" : "[account:name]",
          "param_user_to_notify" : [ "account" ]
        }
      }
    ]
  }
}

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

Note that the 15552000 is the equivalent of 6 months in seconds. You may want to reduce that a bit, e.g. with a number of seconds equivalent to a few days (or a week or so). That way the eMail will be triggered a few days before the actual renewal.

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.