Previously in my blogger setup, whenever a comment was posted, I used to get an email notification that there was a comment in my post. So I would go and check immediately and reply to the comment. In the drupal set up, there was no out of the box feature that would send an email on a new comment to a post. I used to see the recent comment block on the right and then know whether someone had commented or not. But this was a bad idea as I used to display only about 10 latest comments and if there were more comments than those, then I wouldnt know about them.

So, I had to dig a little deeper to find how to get email notifications. I read somewhere that triggers can be used to do this. Upon a new comment you can set up a trigger to do some task. I found out that this task is called an action. So basically, you set up multiple actions that you want the system to do at various points of time. Then you set up triggers that fire these actions at given instances of time. So one can use this trigger-action concept to set up automated email notifications too upon a new comment to a post.

The first step is to define an action. By default an email action will not be defined, so you have to do this yourself. Go to the administer->site configuration->actions or admin/settings/actions menu area. Here, scroll down to the advanced actions dropdown and create a new action of type ‘send email…’. Customize this action by defining the recipient, subject and body of the email. Interestingly you can make this as dynamic as you can get by using the predefined variables. I, for example, entered ‘%author’ as the recipient. This will send an email directly to the email address configured for the user name who is the author of the post. Also in the body, I have used the variables ‘%title’ and ‘%node_url’ to point to the post under which the comment has been added. This allows me to directly navigate to the post where the comment is entered and give my replies there.

Once the action is configured and saved, we have to set up the triggers at administer->site building->triggers or admin/build/trigger menu area. Here under the section ‘comments’ and for the trigger ‘after saving a new comment’ assign the action to send the email that you had defined in the previous step. Thats it. Now to test it, go to one of your posts as an anonymous user and leave a comment. If your SMTP is set up correctly, then you should have immediately got a mail at the configured address about the new comment.

Happy commenting with drupal. :)


Sponsored Content



A few related posts