[Drupal] How to send / mail out newly added comments for a node to a specified email address on a Drupal 6 site?
Replying to comments is an extremely good practice for bringing recurring traffic to your Drupal website as you are interacting with your visitors. If you can send those new comments to an email address, you can respond to them quicker since a late reply usually goes unnoticed. Normally in a Drupal 6 website, the admin user has to login to the website and moderate the comments which often leads to a significant delay in response time. Check out our instructions on how to send comments to an email address in a Drupal 6 website.
This feature requires only a few configuration changes. The feature consists of a trigger - action pair. The trigger is/occurs when a user puts a comment somewhere on your Drupal website. The action would obviously be to send the contents of the mail to the desired email address. Before we play with the configuration, we require the following modules to be enabled on the website.
- Token module
- Token actions module
- Triggers module
- Actions module
After enabling the above modules, we need to create the action which is to send an email with all the details of the comment. Steps are as follows. We are assuming that you have the Admin menu module installed and enabled, although it is not necessary.
Creating the action
- Select Admin Menu -> Site Configuration -> Actions -> Manage Actions
- Select "Send tokenized email " from the options in the page and click on Create.
- In the following page update the fields with the requirements.
- In the message field, enter the message with the required tokens. For eg:
### A new comment has been posted on: "[title]" You can checkout the comment at : [site-url]/node/[comment-nid]#comment-[comment-cid] ### Comment information: Title: "[comment-title]" Body: [comment-body-raw] Submitted by: [comment-author-name] on [comment-ddd], [comment-mm]/[comment-dd]/[comment-yyyy] ### Please review the comment approval queue at: [site-url]/admin/content/comment/approval
The text in the square brackets are known as tokens in the Drupal world. The tokens act as placeholders for the actual content. The 'Token Actions' module along with the 'Token' module work to replace the tokens with the actual info of the comment when the email is send.
You can format the email according to your requirement. The above is just a template for reference.
Now save the changes.
Creating the trigger
Since we now have the action, we need to set the trigger to call the action.
- If you have saved the action, you will be presented with the option to go to the trigger page (admin/build/trigger)
- Select the "Comments" tab in the trigger page.
- In the fieldset - Trigger: After saving a new comment, select the newly created action from the drop down list
- Click on assign.
Now post a comment and check your inbox to see if everything has appeared as correctly as expected.