Roundcube Community Forum
Third Party Contributions => Old Style Plug-Ins => Topic started by: Steve Corona on October 05, 2007, 02:40:16 PM
-
Hi everyone. We use Roundcube for our companies webmail solution. Unfortunately, we get tons of SPAM- somewhere in the range of about 5/minute. Our MTA filters most of them out and the few that get through are processed by SpamAssassin. Our SpamAssassin setup appends "*****SPAM*****" to the subject line of the email but doesn't remove them from the inbox. This can be a real pain with webmail because the spam emails still clog up your inbox.
So, to combat this situation I wrote up a very simple patch today. It moves all of the email with a specified string into the junk folder, automatically. It's customizable so whatever your email system uses to mark spam- "[SPAM]", "*****SPAM*****", whatever, it can work. It's also very easy to install, you only need to replace one file and add a single configuration option into your main.inc.php file.
You can view the patch here:
http://fusionreactions.com/pages/rcmail (http://fusionreactions.com/pages/rcmail)
Hope it can be useful to everyone. If you have any questions post them here and I'll try to help you. Also, if you're interested in any custom patches please use the contact form on our website. We'd be glad to discuss any opportunities with you.
Enjoy,
Steve Corona
Web Director
Fusion Reactions
-
Thanks for the post!
-
There is a bug that I missed- SPAM filtering doesn't happen when you login, you need to click on the Inbox after logging in to remove the SPAM.
I'm currently working on a general filtering plug-in right now. I'm thinking a configuration page where you can setup rules to move mail to an arbitrary folder depending on the subject/sender/body/date/etc.
Cheers
Steve Corona
Web Director
http://www.fusionreactions.com (http://www.fusionreactions.com)
-
Nice addition.
It would be nice if one could set the parameter in GLOBAL and this is inherited to user config. The user can then set the string in preferences (by adding label en input field)?
Would it not be nice to add the check for the SPAM string to the beginning of the loop? or add a separate loop before the column format algorithm?
Does the SPAM string need some checking against illegal characters?
regards, Sean
-
Does this filter subject only? or will it also filter by header info?
-
I haven't been able to get this to work with version 0.1-rc2. Can anyone else confirm this?
I get a blank page after trying to log in...
-
Hi,
@seansan
What do you mean set the param in GLOBAL? The param is set in the config file to change the subject it filters.
@mrjaguar
It only filters the subject. I'd like to eventually add header filtering but I don't have the time yet.
@thetimp2003
I havn't tested it in RC2 yet. I am still running RC1, I'll let you know what changes need to be made if I get time to update our companies roundcube installation today.
-
I mean that a user can set the string in the CONFIG (actually the admin). This variable is then set as default on the user level. I can imagine that different users (maybe not on your system) have different SPAM strings in the attachment. The variable is then also accesible via the preferences window - where a user can override the default value.
-
I mean that a user can set the string in the CONFIG (actually the admin). This variable is then set as default on the user level. I can imagine that different users (maybe not on your system) have different SPAM strings in the attachment. The variable is then also accesible via the preferences window - where a user can override the default value.
Ah- so you are saying, a per user spam string rather than a global one? When I get some time I'd like to improve this script, we'll see what I'm up to this weekend.
Steve Corona
Web Director
Fusion Reactions
-
This patch is broken in RC2. I'm going to have a fix out today :)
-
This patch is broken in RC2. I'm going to have a fix out today :)
Nice, I'm waiting for it :)
Thank you very much for your work.
-
This patch is broken in RC2. I'm going to have a fix out today :)
I've modded your patch for the RC2, You can dl it here : http://temp.leveilleur.net/func.rar
So, Your patch work very well, just the little bug that you already know. (Must click on the inbox folder after the login)
-
I've modded your patch for the RC2, You can dl it here : http://temp.leveilleur.net/func.rar
So, Your patch work very well, just the little bug that you already know. (Must click on the inbox folder after the login)
I had to slightly modify your patch because strpos return 0 (==false) if the subject header begins with the SPAM tag :
if ( ( strpos( $cont, $CONFIG['spam_subject']) ) && ( $mbox != $CONFIG['junk_mbox'] ) ) {
is now
if ( ( preg_match($CONFIG['spam_subject'],$cont) ) && ( $mbox != $CONFIG['junk_mbox'] ) ) {
and my config line is now
$rcmail_config['spam_subject'] = '/^\*\*\*SPAM\*\*\*/';
as my spamassassin tags spams with ***SPAM***. Works perfectly for me now.
Thanks all for this nice patch.
-
Le Veilleur's patched worked perfectly with Pierre's modification :)
Thanks very much to both of you :)
Anyone had any luck with the having to click on Inbox again issue?
-
I had add some code to filter only INBOX, because, some mailbox should not be filtered.
This code is for filter only in INBOX
if ( $mbox=='INBOX' ) {
if ( ( preg_match($CONFIG['spam_subject'],$cont) ) && ( $mbox != $CONFIG['junk_mbox'] ) ) {
$is_spam = 1;
}
}
OR, filter for others except Trash
if ( $mbox!=$CONFIG['trash_mbox'] && $mbox!=$CONFIG['junk_mbox'] ) {
if ( preg_match($CONFIG['spam_subject'],$cont) ) {
$is_spam = 1;
}
}
-
Hi,
Since RC2, the func file has completely changed. I cannot use the patch anymore :(
Thanks.
-
It does work. Just use Le Veilleur's file, and the optional modification below his post.
-
My bad.
Sorry
Works like a charm
-
There is one or two things though.
Have any of you problems deleting mail from Junk folder. If i delete a message, then go to Trash, and then go back to Junk again, it's still there.
The other stuff is in the log.
[29-Dec-2007 13:20:35] PHP Fatal error: Call to undefined function rcmail_deliver_message() in /home/httpd/html/roundcube/program/steps/mail/sendmail.inc on line 306
&
[28-Dec-2007 14:45:05] PHP Fatal error: Cannot redeclare rcmail_mailbox_list() (previously declared in /home/httpd/html/roundcube/program/include/main.inc:1595) in /home/httpd/html/roundcube/program/steps/mail/func.inc on line 144
Hopefully we can get a new file which is up to date...
-
Ok, with the old func.inc file, you can't send mail. We need an update for this asap.
Please check if you can send mail, and report back.
-
The last post is old, i know, but if also someone is wondering, why deleted junkmails never could be deletet, just add this code
if ( $mbox=='INBOX' ) {
if ( ( preg_match($CONFIG['spam_subject'],$cont) ) && ( $mbox != $CONFIG['junk_mbox'] ) ) {
$is_spam = 1;
}
}
to the patch.
Hope this helps someone.
-
Is this patch works with 0.2 stable?
-
Hello
In 0.2 stable I manually put lines like this into func.inc:
// START MODIFICATION (1 of 4) BY steve@fusionreactions.com - SPAM FIX
[...]
// END MODIFICATION
Because when I replace func.inc Roundcube don't work. If someone want's I can do a patch file
But problem was in main.inc:
$rcmail_config['spam_subject'] = '***SPAM***';
I don't know how describe tag which puts Spamassassin. Listed above doesn't work.
Works:
$rcmail_config['spam_subject'] = 'SPAM';
But how to do something like this /^\*\*\*SPAM\*\*\*/ in that var?
Regards, Peter
-
I don't know how describe tag which puts Spamassassin. Listed above doesn't work.
Works:
$rcmail_config['spam_subject'] = 'SPAM';
But how to do something like this /^\*\*\*SPAM\*\*\*/ in that var?
Regards, Peter
Hello,
try something like this for ***SAPM***:
$rcmail_config['spam_subject'] = '/^\*\*\*SPAM\*\*\*/';
or you can also change the comment from SpamAssassin about your setting for the mailbox.
Regards, fkw
-
Does anyone prepare for 0.2stable patch of this plugin?
-
Hello everyone. It seems there isn't no comments in this topic for a long time... :confused:
I work in a brazilian university and recently we adopted Roundcube 0.2 as our webmail client. Well, spams are a huge problem here and we have lots of users complaining about some kind of spam filtering.
To resolve this e adapted the code presented in this topic and I could get the messages tagged by spamassassin moved to the junk folder.
The problem is that the Inbox unread counter isnĀ“t updated until i click it for the second time and my users continue complaining... :mad:
In my code (inside rcmail_js_message_list function), it seems that the following line used to update INBOX doesn't work at all:
$OUTPUT->command('set_unread_count', 'INBOX', $IMAP->messagecount('INBOX', 'UNSEEN'));
I am a bit confused because after that line i added the following one to actualize the junk_box unread message counter and it worked pretty well:
$OUTPUT->command('set_unread_count', $CONFIG['junk_mbox'], $IMAP->messagecount($CONFIG['junk_mbox'], 'UNSEEN'));
Can anyone help me?
PS.: If a solution was developed since 2007 I would be very glad to know.
-
It's sad this fix doesn't work anymore.
Will there any in the future ?
Spam is a big problem for me, i'm searching for a solution.
-
Ok.
I found a script by midnightz ( http://www.roundcubeforum.net/plug-ins/2565-replacement-easy-spamassassin-filtering.html )
I just made it more simple :
You just have to edit ./program/steps/mail/func.inc, ~line 245
After :
// create row for each message
foreach ($a_headers as $i => $header) //while (list($i, $header) = each($a_headers))
{
Add :
// ******************************************************
// ADD by woOtzee.com SPAM FIX
$spamfix_subject = Q(rcube_imap::decode_mime_string($header->subject, $header->charset));
if ($mbox!=$CONFIG['trash_mbox'] && $mbox!=$CONFIG['junk_mbox']) {
if (preg_match("'^\[SPAM\]'",$spamfix_subject) && !$header->seen) {
$IMAP->move_message( array($header->uid), $CONFIG['junk_mbox'], $mbox );
continue;
}
}
// ADD by woOtzee.com SPAM FIX
// ******************************************************
All unread mail marked as spam will be redirect to your junk box.
If you se a mail witch isn't spam in junk box, just mark it as read, and put it again
in the inbox box.
But, you need to clic on the mail icon on the top of the page to make it works.
If your spam tag isn't [SPAM] but, ***SPAM*** for exemple, like in the begin of
this post, just replace :
^\[SPAM\]
by :
/^\*\*\*SPAM\*\*\*/
Hope there's no mistake, it works for me !
-
Hello together,
is there now any Version of this SpamAssassin Filter which works definitivly with the newest roundcube version (0.2.1) ?
I use 0.1 untill now because i need this plugin :/
Thankst for your help.
-
@woOtzee: First of all thanks a lot for your fix. But do I overlook something? I've inserted your code (in my case for "***SPAM***") at the place you told, but I don't see anything happen. Do I add other code too? Is this really working for 0.2.1 stable?
// **************************************************
// ADD by woOtzee.com SPAM FIX
$spamfix_subject = Q(rcube_imap::decode_mime_string($header->subject, $header->charset));
if ($mbox!=$CONFIG['trash_mbox'] && $mbox!=$CONFIG['junk_mbox']) {
if (preg_match("'/^\*\*\*SPAM\*\*\*/'",$spamfix_subject) && !$header->seen) {
$IMAP->move_message( array($header->uid), $CONFIG['junk_mbox'], $mbox );
continue;
}
}
// ADD by woOtzee.com SPAM FIX
// **************************************************
Best regards,
Dawn
-
Hello dawn.
I've copied your Code.
But it doesn't work.
Mails with ***SPAM*** in the subject stay in my standard inbox.
Any other idea how i can filter spam mails?
-
Any news here? A patch for the current version would be nice, since my provider does not use Sieve etc. I have to move the spam messages afterwards in roundcube.
-
The script is not working for the current version of RoundCube (0.4.2). Does anyone have a working one?
-
// ******************************************************
// ADD by woOtzee.com SPAM FIX
$spamfix_subject = Q(rcube_imap::decode_mime_string($header->subject, $header->charset));
if ($mbox!=$CONFIG['trash_mbox'] && $mbox!=$CONFIG['junk_mbox']) {
if (preg_match("'^\[SPAM\]'",$spamfix_subject) && !$header->seen) {
$IMAP->move_message( array($header->uid), $CONFIG['junk_mbox'], $mbox );
continue;
}
}
// ADD by woOtzee.com SPAM FIX
// ******************************************************
The script works for me even in version 0.4.2, but there's one detail: The message count in the folder panel does not work properly.
When I start roundcube and there is a spam message within the inbox, the message is moved instantly, but there remains a (1) for the inbox in folder panel until the next time roundcube checks for new mails or manual refresh.
I'm looking for some code which brings roundcube to count again after moving the message... ???
-
The script works for me even in version 0.4.2, but there's one detail: The message count in the folder panel does not work properly.
Where did you put this part of code?
In 0.3.1 everything was fine, but in 0.4.2 I can't find suitable place in /program/steps/email/func.php for this :(