diff -Naur /tmp/org/spam_buttons/config.php.sample /usr/share/smtest/plugins/spam_buttons/config.php.sample
--- spam_buttons/config.php.sample	2006-01-21 19:33:31.000000000 +0100
+++ spam_buttons/config.php.sample	2006-01-22 10:20:09.040210411 +0100
@@ -7,7 +7,7 @@
        $spam_report_email_method, $is_spam_subject_prefix, $is_not_spam_subject_prefix,
        $show_is_spam_button, $spam_report_smtpServerAddress, $spam_report_smtpPort,
        $spam_report_useSendmail, $spam_report_smtp_auth_mech, $spam_report_use_smtp_tls,
-       $sb_debug;
+       $spam_folder, $sb_debug;
 bindtextdomain('spam_buttons', SM_PATH . 'locale');
 textdomain('spam_buttons');
 
@@ -36,6 +36,21 @@
 
 
 
+// Optional Spam folder. If you specify this parameter some special
+// action will occur:
+//
+// - If $show_is_spam_button is set to 1, then Spam button shows up 
+//   in all folders (except $spam_folder).
+// - If you hit Spam button, then an additional action will be taken
+//   and the message will be moved to $spam_folder.
+// - If $show_not_spam_button is set to 1 AND the current folder is
+//   $spam_folder, then non-spam button will be available. If you then
+//   hit the no-spam button, the message will be moved to INBOX folder.
+//
+$spam_folder = 'Spam';
+
+
+
 // Show spam buttons on message list page?
 //
 // 0 = no, 1 = yes
diff -Naur /tmp/org/spam_buttons/functions.php /usr/share/smtest/plugins/spam_buttons/functions.php
--- spam_buttons/functions.php	2006-01-21 19:33:31.000000000 +0100
+++ spam_buttons/functions.php	2006-01-22 10:17:00.714414765 +0100
@@ -23,9 +23,9 @@
    global $is_spam_shell_command, $is_spam_resend_destination,
           $is_not_spam_shell_command, $is_not_spam_resend_destination,
           $is_spam_subject_prefix, $is_not_spam_subject_prefix;
+   global $username, $key, $imapServerAddress, $imapPort;
    include_once(SM_PATH . 'plugins/spam_buttons/config.php');
 
-
 //sm_print_r($_GET, $_POST, $_SERVER);
 //sm_print_r($_SESSION);
 //exit;
@@ -83,11 +83,10 @@
    textdomain('spam_buttons');
 
 
-
+   sqgetGlobalVar('mailbox', $mailbox);
    $note = '';
 
 
-
    // -----------------------------------------------------------------
    //
    // SPAM
@@ -109,6 +108,21 @@
          if (empty($note)) $note = _("Successfully reported as spam");
 //TODO? include something that identifies the message(s) that were reported(have to add it up in the loop above)?  might take too much screen real estate....?
 
+ 	 if (!empty($spam_folder)) {
+	    $imap_stream = sqimap_login($username, $key, $imapServerAddress,
+					$imapPort, 0);
+	    if (sqimap_mailbox_exists($imap_stream, $spam_folder)) {
+		sqimap_mailbox_select($imap_stream, $mailbox);
+    		foreach($msg as $i => $v) {
+		    if (sqimap_msgs_list_copy($imap_stream, $v, $spam_folder)) {
+    			sqimap_toggle_flag($imap_stream, $v, '\\Deleted', true, true);
+		    }
+		}
+	    } else {
+	        $note = sprintf(_("Error: Spam folder %s does not exist."), $spam_folder);
+	    }
+	    sqimap_logout($imap_stream);
+	}
       }
 
 
@@ -155,6 +169,21 @@
          if (empty($note)) $note = _("Successfully reported as non-spam");
 //TODO? include something that identifies the message(s) that were reported(have to add it up in the loop above)?  might take too much screen real estate....?
 
+ 	 if (!empty($spam_folder)) {
+	    $imap_stream = sqimap_login($username, $key, $imapServerAddress,
+					$imapPort, 0);
+	    if (sqimap_mailbox_exists($imap_stream, $spam_folder)) {
+		sqimap_mailbox_select($imap_stream, $spam_folder);
+    		foreach($msg as $i => $v) {
+		    if (sqimap_msgs_list_copy($imap_stream, $v, 'INBOX')) {
+    			sqimap_toggle_flag($imap_stream, $v, '\\Deleted', true, true);
+		    }
+		}
+	    } else {
+	        $note = sprintf(_("Error: Spam folder %s does not exist."), $spam_folder);
+	    }
+	    sqimap_logout($imap_stream);
+	}
       }
 
 
@@ -249,7 +278,6 @@
 }
 
 
-
 /**
   * Reports one or more spam/non-spam using email redirection.
   *
@@ -575,18 +603,21 @@
 {
 
    global $show_not_spam_button, $spam_button_text, $not_spam_button_text,
-          $show_is_spam_button;
+          $show_is_spam_button, $spam_folder;
    include_once(SM_PATH . 'plugins/spam_buttons/config.php');
 
 //TODO: create tooltip with more verbose explanation 
    $ret = '';
+   sqgetGlobalVar('mailbox', $mailbox);
 
    if ($show_is_spam_button)
+    if (empty($spam_folder) || $mailbox != $spam_folder)
       $ret .= '<input type="submit" name="isSpam" value="' . $spam_button_text . '" />';
 
    if ($show_not_spam_button)
+    if (empty($spam_folder) || $mailbox == $spam_folder)
       $ret .= '<input type="submit" name="notSpam" value="' . $not_spam_button_text . '" />';
-
+    
    return $ret;
 
 }
@@ -601,7 +632,8 @@
 {
 
    global $show_spam_link_on_read_body, $show_not_spam_button, 
-          $spam_button_text, $not_spam_button_text, $show_is_spam_button;
+          $spam_button_text, $not_spam_button_text, $show_is_spam_button,
+	  $spam_folder;
    include_once(SM_PATH . 'plugins/spam_buttons/config.php');
 
    if (!$show_spam_link_on_read_body)
@@ -613,20 +645,20 @@
    sqgetGlobalVar('startMessage',  $startMessage,  SQ_FORM);
    sqgetGlobalVar('view_as_html',  $view_as_html,  SQ_FORM);
 
-
 //TODO: create tooltip with more verbose explanation 
    if ($show_is_spam_button)
+    if (empty($spam_folder) || $mailbox != $spam_folder)
       echo ' | <a href="' . SM_PATH . 'src/read_body.php?isSpam=yslnk&mailbox=' 
          . urlencode($mailbox) . '&passed_id=' . $passed_id . '&view_as_html='
          . $view_as_html . '&startMessage=' . $startMessage . '">' 
          . $spam_button_text . '</a>';
    
    if ($show_not_spam_button)
+    if (empty($spam_folder) || $mailbox == $spam_folder)
       echo ' | <a href="' . SM_PATH . 'src/read_body.php?notSpam=yslnk&mailbox='
          . urlencode($mailbox) . '&passed_id=' . $passed_id . '&view_as_html='
          . $view_as_html . '&startMessage=' . $startMessage . '">' 
          . $not_spam_button_text . '</a>';
-
 }
 
 
--- spam_buttons/setup.php	2006-02-06 13:30:01.000000000 +0100
+++ spam_buttons/setup.php	2006-02-10 20:46:27.749869819 +0100
@@ -37,7 +37,6 @@
 
 
 
-   $squirrelmail_plugin_hooks['read_body_header_right']['spam_buttons']   = 'sb_read_message_links';
 
 }
 
