Email Drupal Comments for Approval to Admin Email Address

Saturday, October 17th, 2009
Last Updated:
Sunday, February 21st, 2010

Disclaimer: Accessing the information on this page means you agree to the Sites Terms of Service

The Need

Back in the Drupal 5 days, there was a wonderfully made little module called: Comment Mail that would e-mail the site administrator if there were any new comments on the site needing approval. While there is a D6 version of the module, it has not been maintained since Nov 2008 and even posts that there are some bugs with the module. This inspired me to figure out a way of doing the same thing with a few other modules. While I believe the way I have devised is a bit overkill, it does the job :)

Now, some may be saying "Why not just use Drupal 6 Actions and Triggers?" The reason is because it doesn't really give any usable support for tokenized messages... (D7 is supposed to be different... I hope...) Since the "Token Actions" for Drupal... well... completely sucks, I decided to use the Rules module instead which pulls the full functionality of the Token module into play... Top it off with the LoginToboggan module and you are ready for comment approval e-mails to start flooding in! There is another post on which gives great instructions on how to setup the rules module to do all of this, but he didn't go into detail on how to really make the e-mail message shine. This is where I want to kind of pickup where he left off... I will explain how to set everything up from start to finish, but if you need some help with the rules, you might check his site.

The Modules

Modules needed:

Suggested Modules:

The Explanation

First off, the Rules module is VERY powerful in what it can do with Drupal... It might seem a bit intimidating but don't let it scare you. After you make a few rules, it's one of those "Ooohh... I see what they're doing!" scenarios.

The Token module is a passive module meaning there aren't any configuration screens for it. If another module needs it and it's there, you get a list of tokens to use. That simple. Chances are, if you are using Pathauto, you are already using the Tokens module.

The (optional) LoginToboggan is more a site where there are a lot of users, but there is one little itty-bitty setting that needs to be turned on for everything to come together smoothly.

The Instructions

1) Install the Rules module, enabling the following:
Rules, Rules Administration UI
2) Install the Token module, enabling the following:
3) (Optional) Install the LoginToboggan module enabling the following:
4) Rules creates it's own administrative menu. Go to Rules -> Triggered rule -> Add a new rule
5) On the triggered rule page, let's setup the following:
Label: Comment Approval
Event: After saving a new comment
Categories: comments

Leave the check next to: This rule is active and should be evaluated when the associated event occurs.

Weight: (You can leave at 0)

Click the Save changes button.

You should now see a screen that shows:

ON event After saving a new comment
+ Add Action

+ Add Action

6) Click on the + Add Action link under DO
7) On the Add Screen, set the following:
Select an action to add: Send a mail to an arbitrary mail address

Click Next

8) You should now be on a screen called: Editing action Send a mail to an arbitrary mail address On this screen, most of the elements should be pretty self-explanatory, but let's go through them:
Recipient: (your e-mail address)
Sender: (should be good to leave blank...)
Subject: (something like:) Website Comment Approval
Message: (copy and paste the following:)
A new comment has been posted on: [comment:site-url] at the following location: [comment:site-url]/node/[comment:comment-nid]#comment-[comment:comment-cid]

Approve the comment:

Name: [comment:comment-author-name-raw]
Email: [comment:comment-author-mail-raw]
Homepage: [comment:comment-author-homepage]
Subject: [comment:comment-title-raw]


Weight: (Just leave at 0)

Click Save

9) (Optional LoginToboggan) Go to User management -> LoginToboggan

Scroll all the way to the bottom to the Other section and set the following:
Present login form on access denied (403): Enable

Note: If you have multiple users that login to your site, you might want to go through the LoginToboggan settings a little more in-depth to make sure the login & registration process is to your liking.


That's It! Go send yourself a comment and test it out! : )

If you want to customize the e-mail message, feel free to play around with the different tokens available. What I have presented is probably enough information for most folks... Keep in mind though, that the actual comment URL won't work right until the comment has been approved.

Update: 2010/02/21 It was brought to my attention that Token Actions will allow you to create an advanced action as "send tokenized email..." using the core Drupal Triggers / Actions. While I suppose this could be used to construct the above Rules, I personally have not tested it's output to see if the e-mail generation is similar to the Rules option above. Theoretically though, it should work pretty much the same.

Post Comment


Thanks for this page. I'm still on Drupal 6, and finally decided to get off my butt and get comment email notification working. I found your page, and got it working with no problems! Thanks!

You said: "Token Actions" for Drupal... well... completely sucks.

What's wrong with Token Actions?

What can you do with Rules that you cant to with Actions/Triggers and Token Actions?

The reason I don't like Drupal Triggers with Token actions, is due to the actual form layout of the core Drupal Actions. While it provides a great basis for basic trigger response actions on the site, it does not provide a way (that I have found) to un-publish nodes after a certain period of time after it was created, or reset the timer to un-publish again after set to re-publish. It can be fine tuned whereas the core Drupal Actions is more of an "if this, then that" type of workflow. Rules gives a much more fine tuned functionality as an overall workflow.

It was a while ago when I tried to create a tokenized e-mail message and I apparently missed the "send tokenized e-mail" in the Drupal Advanced Actions. I supposed that will do what a person needs it to do, but for some reason, it seems like it still didn't output what I expected in the e-mail message.

One gripe I have on BOTH rules and Actions is the inability to use HTML markup within the forms to send e-mail messages. I understand that some e-mail clients don't recognize HTML etc. etc. but it would be nice to have even more control of how the e-mail message looks on the final output. I'm not a programmer so I don't really know what goes on under the hood of Drupal to know why this isn't available. Same goes for the "Footer" of the Drupal "Site Information" area. Why no html or for that matter PHP markup? I've had to create a block and stick it at the footer as my workaround which makes the core Drupal footer rather useless to begin with... That's another rant for another day.

David Newkerk also points out that Triggers/Actions is very basic stating: "Important: the default Trigger/Actions module that comes with Drupal 6 core is relatively basic and while it can specify and execute a a variety of Triggers and Actions, it is limited in how specific they can be and what actions they can perform. For more complex functionality, you will need the Rules module. Before proceeding, you should decide ahead of time which to use, based on the functionality you need." He goes on to say: "Trigger module cannot specify which Content types it will act on." Read more

So see? I'm not the only one who has run into problems using Trigger / Action / Token / Token Actions.

Thanks for the response and for sharing your example. This has helped me. I opted to go for Action/Triggers/Token Actions though just because I wanted to stick to the core Drupal modules as much as possible (Trigger/Actions) and I heard that Token/Token Actions will be included Drupal 7 core.

In case it will help others, here's my Trigger/Action configuration that worked for me:

Action: Send tokenized comment notification e-mail
Recipient: [site-mail]
Subject: [[site-name]] New Comment for Approval

A new comment has been posted on your [type-name]:
"[title]" at:

Comment information:
Submitted by [comment-author-name] on [comment-ddd], [comment-mm]/[comment-dd]/[comment-yyyy]


Please review the comment approval queue at:

Just add this action to the trigger:
"After saving a new comment"

That's it.. I like the simplicity as well.

I was just thinking to myself a bit ago: "I wonder if I should create a tutorial on how to create a tokenized e-mail using the core Drupal Triggers / Actions & Token Actions" But it looks like you beat me to it :)

Thinking back, I don't remember why I couldn't get Actions to work like I wanted to... now I'm wondering if I had Token Actions enabled, whether Token Actions was actually working right or if I just had one of those brainfart days... I'm thinking now it was probably the latter. :D

BTW, I noticed you have the <em></em> tags in the tokenized message... were you able to get those to actually output properly in the e-mail??

Sorry for the confusion - the em tag was supposed to be just for this comment i'm posting :) to highlight the actual text i had in there for the tokenized message text box. thought those are part of your "allowed html tags". just ignore that and use everything in between for the message.