Drupal's Triggers and Actions for Automatic E-Mail Notifications
I just ran into a situation that required me to set up an advanced action that would be triggered by comments. One of the websites that I currently maintain has a situation where there are 5 or 6 users that need to be notified when users in the customer role leave comments on certain content-types.
Because I use the token module on the site, I have available as one of the options at admin/settings/actions to 'Send a tokenized email...'.
The tokenized email is way better than the option of sending a regular email because you have access to all those cool token replacements in the subject and body of the email. I wanted my users to be about to see who made the comment, the node title of the page the comment was made made on and also the date of the comment. Basically that would be enough to determine if the comment was relevant to them or if they could just delete that email.
Now, all the users in the list that I needed to receive emails are in the same role so I really wanted to use the Action Email Role module but it turns out that so far that module has no support for token.
Ok, so since there is no more than 6 people, I created 6 actions, one for each user that would receive an email.
For the Subject i put the following:
A comment was left by [user-name] for [title] on [comment-ddd], [comment-mon] [comment-date], [comment-yyyy]
which prints like this:
A comment was left by twooten for 09WT66 on Fri, Dec 5, 2009
and the body:
[comment-body] You can view the complete job by clicking the following link: [site-url]/job/[title]#comment-[comment-cid]
That satisfies all my requirements quite well.
The only real issue I have with this method is the fact that I have to have a seperate action for each user. If I use the Action Email Role module then that would not be necesarry but it would also break the requirements I have for the subject and body using token replacements. Sure enough the emails would be sent but I can not format the email like I want.
I can live with the 6 actions for now and wait on the Action Email Role to become "token aware". This could be taken care of with a module but I have run out of hours to take on that just yet.
