--- actions.inc	Sat Jan 29 16:00:36 2005
+++ actions.inc.new	Mon Oct  3 14:12:30 2005
@@ -370,10 +370,22 @@
       break;
   
     case 'do':
-      $recipient = $edit['recipient'];
+      $user = user_load(array('uid' => $node->uid));
+      $from = variable_get('site_mail', ini_get('sendmail_from'));
+      $site_name = variable_get('site_name', 'Drupal');
+      $from = "$site_name <$from>";
+      if ($edit['recipient'] == 'author') {
+        $recipient = $user->mail;
+      } else {
+        $recipient = $edit['recipient'];
+      }
+      print $recipient;
+      $variables = array('%username' => $user->name, '%node_url' => url('node/' . $node->nid, NULL, NULL, TRUE), '%node_type' => $node->type, '%node_title' => $node->title, '%site_name' => $site_name);
       $subject = $edit['subject'];
-      $message = $edit['message'];
-      if (user_mail($recipient, $subject, $message, '')) {
+      $site_name = variable_get('site_name', 'Drupal');
+      $url = url('node/' . $node->nid, NULL, NULL, TRUE);
+      $message = strtr($edit['message'], $variables); 
+      if (user_mail($recipient, $subject, $message, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from" )) { //SD modified
           watchdog('action', t('Sent email to' . " $recipient"));
       }
       else {
@@ -389,9 +401,9 @@
       if (!isset($edit['message'])) $edit['message'] = '';
        
       // add form components
-      $output  = form_textfield(t('Recipient'), 'recipient', $edit['recipient'], '20', '254', t('The email address to which the message should be sent'));
+      $output  = form_textfield(t('Recipient'), 'recipient', $edit['recipient'], '20', '254', 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.'));
       $output .= form_textfield(t('Subject'), 'subject', $edit['subject'], '20', '254', t('The subject of the message'));
-      $output .= form_textarea(t('Message'), 'message', $edit['message'], '80', '20', t('The message that should be sent'));
+      $output .= form_textarea(t('Message'), 'message', $edit['message'], '80', '20', t('The message that should be sent.  You may include the following variables: %site_name, %username, %node_url, %node_type, %node_title'));
       return $output;
       break;
      
@@ -399,7 +411,7 @@
     case 'validate':
       $errors = array();
   
-      if (!valid_email_address($edit['recipient'])) {
+      if (!valid_email_address($edit['recipient']) && $edit['recipient'] != 'author') {
         $errors['recipient'] = t('Please enter a valid email address.');       
       }
       foreach ($errors as $name => $message) {
@@ -420,4 +432,4 @@
   } 
 }
 
-?>
\ No newline at end of file
+?>
