Index: actions/actions.install
===================================================================
--- actions/actions.install	(revision 21)
+++ actions/actions.install	(working copy)
@@ -96,4 +96,31 @@
       break;
   }
   return $ret;
+}
+
+/**
+ * Change all old email actions that use %author to new %author-mail since
+ * we're using token module now.
+ */
+function actions_update_3() {
+  $ret = array();
+  switch ($GLOBALS['db_type']) {
+    case 'mysqli':
+    case 'mysql':
+    case 'pgsql':
+      $result = db_query("SELECT aid, params FROM {actions} WHERE func = 'action_send_email'");
+      while ($action = db_fetch_object($result)) {
+        $action->params = unserialize($action->params);
+        if ($action->params['recipient'] == '%author') {
+          $action->params['recipient'] = '%author-mail';
+          $action->params = serialize($action->params);
+
+          // Use db_query as it's much cleaner with the serialized array.
+          db_query("UPDATE {actions} SET params = '%s' WHERE aid = %d", $action->params, $action->aid);
+          $ret[] = array('success' => TRUE, 'query' => t('Updated %author token to %author-mail in action ID @d.', array('@d' => $action->aid)));
+        }
+      }
+      break;
+  }
+  return $ret;
 }
\ No newline at end of file
Index: actions/actions.inc
===================================================================
--- actions/actions.inc	(revision 21)
+++ actions/actions.inc	(working copy)
@@ -310,26 +310,12 @@
       $from = variable_get('site_mail', ini_get('sendmail_from'));
       $subject = $edit['subject'];
       $message = $edit['message'];
-      if ($edit['recipient'] == t('%author')) {
-        $recipient = $user->mail;
-      } else {
-        $recipient = $edit['recipient'];
-      }
-      if (isset($node) && is_object($node)) {
-        $variables = array(
-          '%site_name' => $site_name,
-          '%username' => $user->name,
-          '%uid' => $node->uid,
-          '%node_url' => url('node/' . $node->nid, NULL, NULL, TRUE),
-          '%node_type' => $node->type,
-          '%title' => $node->title,
-          '%teaser' => strip_tags($node->teaser),
-          '%body' => strip_tags($node->body)
-           );
+      $recipient = token_replace($edit['recipient'], 'node', $node, '%', '');
 
-        $subject = strtr($subject, $variables);
+      if (isset($node) && is_object($node)) {
+        $subject = token_replace($subject, 'node', $node, '%', '');
         $subject = str_replace(array("\r", "\n"), '', $subject);
-        $message = strtr($message, $variables);
+        $message = token_replace($message, 'node', $node, '%', '');
       }
       if (drupal_mail('action_send_email', $recipient, $subject, $message, $from)) {
         watchdog('action', t('Sent email to %recipient', array('%recipient' => $recipient)));
@@ -354,7 +340,7 @@
         '#default_value' => $edit['recipient'],
         '#size' => '20',
         '#maxlength' => '254',
-        '#description' => t('The email address to which the message should be sent OR enter %author if you would like to send an e-mail to the original author of the post.', array('%author' => theme('placeholder', t('%author')))),
+        '#description' => t('The email address to which the message should be sent. You may include variables from the available tokens below.'),
       );
       $form['subject'] = array(
         '#type' => 'textfield',
@@ -362,7 +348,7 @@
         '#default_value' => $edit['subject'],
         '#size' => '20',
         '#maxlength' => '254',
-        '#description' => t('The subject of the message.'),
+        '#description' => t('The subject of the message. You may include variables from the available tokens below.'),
       );
       $form['message'] = array(
         '#type' => 'textarea',
@@ -370,23 +356,19 @@
         '#default_value' => $edit['message'],
         '#cols' => '80',
         '#rows' => '20',
-        '#description' => t('The message that should be sent.  You may include the following variables: %site_name, %username, %node_url, %node_type, %title, %teaser, %body'),
+        '#description' => t('The message that should be sent. You may include variables from the available tokens below.'),
       );
+      $form['tokens_list'] = array(
+        '#type' => 'fieldset',
+        '#title' => t('Available tokens'),
+        '#collapsible' => TRUE,
+        '#collapsed' => TRUE,
+        'list' => array(
+          '#value' => theme('token_help', 'node', '%', ''),
+        ),
+      );
       return $form;
 
-     // validate the HTML form
-    case 'validate':
-      $errors = array();
-
-      if (!valid_email_address($edit['recipient']) && $edit['recipient'] != t('%author')) {
-        $errors['recipient'] = t('Please enter a valid email address or %author.', array('%author' => theme('placeholder', t('%author'))));
-      }
-      foreach ($errors as $name => $message) {
-        form_set_error($name, $message);
-      }
-
-      return count($errors) == 0;
-
     // process the HTML form to store configuration
     case 'submit':
       $params = array(
@@ -406,22 +388,7 @@
   switch($op) {
     case 'do':
       global $user;
-      $variables = array(
-        '%site_name' => variable_get('site_name', 'drupal'),
-        '%username' => $user->name ? $user->name : variable_get('anonymous', 'Anonymous'),
-      );
-      
-      if (isset($node) && is_object($node)) {
-        $variables += array(
-          '%uid' => $node->uid,
-          '%node_url' => url('node/' . $node->nid, NULL, NULL, TRUE),
-          '%node_type' => $node->type,
-          '%title' => strip_tags($node->title),
-          '%teaser' => strip_tags($node->teaser),
-          '%body' => strip_tags($node->body),
-        );
-      }
-      $edit['message'] = strtr($edit['message'], $variables);
+      $edit['message'] = token_replace($edit['message'], 'node', $node, '%', '');
       drupal_set_message($edit['message']);
       break;
 
@@ -441,8 +408,17 @@
         '#default_value' => isset($edit['message']) ? $edit['message'] : '',
         '#required' => TRUE,
         '#rows' => '8',
-        '#description' => t('The message to be displayed to the current user.  You may include the following variables: %site_name, %username, %node_url, %node_type, %title, %teaser, %body.'),
+        '#description' => t('The message to be displayed to the current user. You may include variables from the available tokens below.'),
       );
+      $form['tokens_list'] = array(
+        '#type' => 'fieldset',
+        '#title' => t('Available tokens'),
+        '#collapsible' => TRUE,
+        '#collapsed' => TRUE,
+        'list' => array(
+          '#value' => theme('token_help', 'node', '%', ''),
+        ),
+      );
       return $form;
 
     // validate the HTML form
Index: actions/actions.info
===================================================================
--- actions/actions.info	(revision 21)
+++ actions/actions.info	(working copy)
@@ -1,6 +1,7 @@
 ; $Id: actions.info,v 1.1 2006/10/15 21:17:07 jvandyk Exp $
 name = Actions
 description = Provides an API for modules to trigger and respond to Drupal actions.
+dependencies = token
 ; Information added by drupal.org packaging script on 2007-05-03
 version = "5.x-1.x-dev"
 project = "actions"
