In the plugin repository there is a nice and simple "movespam" plugin, but it has some bugs when installed on 0.8-beta.
if you try to move a ***SPAM*** marked message from junk folder to inbox first you get an internal server error
PHP Fatal error: Call to protected method rcube_imap::messagecount() from context 'movespam' in /usr/local/www/roundcube/plugins/movespam/movespam.php on line 50
and even with $movespam_seen set to false in config.inc.php it moves the seen message back to junk
I see no way to contact the plugins mantainer/author as he provides no email address in the plugin file.
I fixed it so it works properly now with 0.8-beta.
here goes the code
<?php
/**
* MoveSpam
*
* Automatically move spam messages to the junk folder based on the subject line.
*
* @version 1.0
* @author Ythan
*/
class movespam extends rcube_plugin
{
public $task = 'mail';
private $open_mbox = 'INBOX';
private $spam_mbox = 'JUNK';
private $spam_text = '***SPAM***';
private $move_seen = false;
function init()
{
$rcmail = rcmail::get_instance();
$this->load_config();
$this->spam_mbox = $rcmail->config->get('junk_mbox', null);
$this->spam_text = $rcmail->config->get('movespam_subject', null);
$this->move_seen = $rcmail->config->get('movespam_seen', null);
if($rcmail->task == 'mail') {
$this->add_hook('messages_list', array($this, 'check_headers'));
}
}
function check_headers($mlist)
{
$rcmail = rcmail::get_instance();
$imap = $rcmail->imap;
$this->open_mbox = $imap->get_mailbox_name();
if(is_array($mlist['messages']) && $this->open_mbox != $this->spam_mbox){
foreach($mlist['messages'] as $message){
if (strpos($message->subject, $this->spam_text) === 0){
if (!$message->seen && $this->move_seen){
$spam_uids[] = $message->uid;
}
}
}
if (count($spam_uids)){
$spam_uids_str = implode(',', $spam_uids);
$imap->move_message($spam_uids_str, $this->spam_mbox, $this->open_mbox);
$unseen_count = $imap->count($this->spam_mbox, 'UNSEEN');
$rcmail->output->command('set_unread_count', $this->spam_mbox, $unseen_count, false);
$this->api->output->command('list_mailbox');
$this->api->output->send();
$this->api->output->command('getunread');
$this->api->output->send();
}
}
}
}