Articles


How to trigger email for custom rule event in Drupal 7

How to trigger email for custom rule event in Drupal 7



Posted byUttam Kotekar,21st Jan 2016

As in my previous post we have discussed about creating a rule event programmatically . Now we will create an action to trigger email for the custom rule event which we have created. Triggering an email via rule is much easier than sending email via code (using drupal_mail of course). Below is steps how we create a rule action and trigger it.

Initially, Go to rules configuration page (admin/config/workflow/rules). You will find "Add new rule", click on it and fill title and tags (if necessary). On "React on event", select the custom rule event that we have created. Since we have added it in group "User", you can find it the User group section and save it.

After saving it, you will be redirected to "Editing reaction rule page". Now here we will add an action for triggering email to the specified user. At the bottom "Actions" section, you need to click "add action" to create action.

Once you click, you will see the page where you can select the action. Select the "send mail" action on "System" sections. Once selected, you will see the page where you can add to address, from address, message subject, message body. Fill all the fields value and save it. Please make use of data selectors to fill values. Thats it. Now you have to just invoke the event via code that we have discussed in my previous post creating a rule event programmatically.

Simply as that :-).

Categories