Drupal - Send a Notification E-mail when a Comment is Posted
To receive an e-mail notification when a new comment is posted, try this (you won't even need to write one line of code):
1. Enable the 'Trigger' Module
Go to admin/modules and enable the Trigger module if it isn't already.
2. Create an Advanced Action
Go to admin/config/system/actions and scroll down to the 'Create an Advanced Action' section. Select 'Send e-mail' from the drop down menu, then press the 'Create' button.
3. Setup the Advanced Action
- Enter a Label for your action, for example "Send an E-mail to Myself when Comments are Posted".
- Enter the recipient e-mail address
- Enter the Subject of the e-mail notification
- Enter the Message for the body of the e-mail
This particular 'Message' will work well:
[site:url]/admin/content/comment/approval [site:url]/comment/[comment:cid]/delete [comment:node:title] [comment:node:url] From: [comment:name] [comment:body]
It contains quick links to approve or delete the comment, it also sends along the node title, a link to the node, the name of the comment poster, and the comment message. If you do not have comments set to require administrative approval, you can leave out the link to admin/content/comment/approval. Use the table of tokens below the message text area for data placeholders in the e-mail to meet your needs.
4. Add the Action to a Trigger
Go to admin/structure/trigger/comment then to the "Trigger: After Saving a New Comment" section, then select the your action from the 'Choose an action' drop down menu, then click the 'Assign' button.
That's it! You now have e-mail notifications for new comments posted on your Drupal site.
Do you have any tricks for comment notifications in Drupal? Please share your thoughts.