Roundcube Community Forum

 

markasjunk2

Started by dziobak, April 08, 2010, 09:19:20 AM

Previous topic - Next topic

dziobak

@JohnDoh

I have problem with markasjunk2. Every message that I'm marking is not learned
[08-Apr-2010 15:16:17 +0200]: /usr/local/bin/sa-learn --configpath=/usr/local/etc/mail/spamassassin/ --spam /usr/local/www/roundcube/temp/rcmSALearnlefltf
[08-Apr-2010 15:16:17 +0200]: array (
  0 => 'Learned tokens from 0 message(s) (1 message(s) examined)',
)
but when i use the same command from shell but on existing message in maildir format, it works OK
sa-learn --configpath=/usr/local/etc/mail/spamassassin/ --spam /tmp/testmessage
Learned tokens from 1 message(s) (1 message(s) examined)

Maybe there is a way to change localization of %f variable to real message in maildir format?

Could you help me?


dziobak

#2
I don't see the answer for my problem in there.
I don't have any errors in markasjunk2 log. I think there is a problem in mail formats. I use a maildir format and i think markasjunk2 uses mbox.
If php code knows a file name of a mail file, it could set in %f variable the location of that file. or it can create in RC_DIR/temp a maildir format file.

JohnDoh

if you want to see the file its creating then try commenting out
unlink($tmpfname); at the bottom of drivers/cmd_learn.php. that way the temp file wont be deleted after the command has run and you can compare the contents with your test file.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

dziobak

Yes the files are creating and there are the same as original

Maybe I have something wrong with my RC config but $_SESSION['username'] have only name before '@' (not '[email protected]' but 'test'), so I have added some lines in cmd_learn.php and change the command to /usr/local/bin/sa-learn --username=%l --configpath=/usr/local/etc/mail/spamassassin/ --spam %f but it doesn't work either.
29     $command str_replace('%u'$_SESSION['username'], $command);
30
31     
if (strpos($_SESSION['username'], '@') !== false) {
32         $parts explode("@"$_SESSION['username'], 2);
33
34         $command 
str_replace(array('%l''%d'), array($parts[0], $parts[1]), $command);
35     }
36 +   else {
37 +       $command str_replace('%l'$_SESSION['username'], $command);
38 +   }

JohnDoh

sorry i dont get it, if your username doesnt contain an @ then %l and %d are irrelevent, just use %u if thats what you want.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

dziobak

#6
what would happen when I login to roundcube as [email protected]? the session user name will be [email protected] but i want to have only test. So when I login as [email protected] it will execute the if statement but when i login as test it will execute else statement. In both cases I have username test

but this doesn't solve the learning problem...

JohnDoh

i still dont get it, how can you have 1 system with two different username formats? The macros (%u, %l, %d) are expanded exactly the same way as they are in the RC core, I am not going to change this. If you have multiple username formats then I suggest you put a check if the config and do it differently for the different formats or add the change you suggested to your copy of the plugin - but then you have to remember to add it again if you upgrade to a newer version.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

dziobak

OK thanks, but could you help me with the main problem with sa-learn?

JohnDoh

sorry i dont really know anything about sa-learn
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

Martian

Several people have had the same problem you are with sa-learn not learning the mail (thus why I linked the thread above).  As far as I know, nobody has figured it out yet.

Sounds like you are further along than I ever got with it though.

Martian

dziobak

I think we can do it, but first there is something wrong with cmd_learn.php.
When i try use sa-learn i debug mode '/usr/local/bin/sa-learn -D --username=test --spam ...' in markasjunk log i see command with '-D' parameter, but in array there is only one line 0 => 'Learned tokens from 0 message(s) (1 message(s) examined)', but should be much much more...

$tmp_command str_replace('%f'$tmpfname$command);
exec($tmp_command$output);


IMO the $output should have every line that the exec function returns, but it haven't. When we will have full logging we will figure it.

JohnDoh

when using the -D option you need to add `2>&1` to the end of you command (eg: `sa-learn -spam %f 2>&1` to redirect standard error to standard output, it will then show up in the markasjunk2 debug log file.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

dziobak

Quote from: JohnDoh;26722when using the -D option you need to add `2>&1` to the end of you command (eg: `sa-learn -spam %f 2>&1` to redirect standard error to standard output, it will then show up in the markasjunk2 debug log file.

Thanks JohnDoh for advice, I have totally forgotten about this.

I have the answer :-)
when running this command from markasjunk2, sa-learn doesn't know where is bayes database. So I have added --dbpath parameter and it works :-)


'/usr/local/bin/sa-learn --username=%u --dbpath /root/.spamassassin/ --configpath=/usr/local/etc/mail/spamassassin/ --spam %f'

fritz001

Quote from: dziobak;26723Thanks JohnDoh for advice, I have totally forgotten about this.

I have the answer :-)
when running this command from markasjunk2, sa-learn doesn't know where is bayes database. So I have added --dbpath parameter and it works :-)


'/usr/local/bin/sa-learn --username=%u --dbpath /root/.spamassassin/ --configpath=/usr/local/etc/mail/spamassassin/ --spam %f'

your spamassassin is missconfigured::

add this line to local.cf

bayes_path = /root/.spamassassin/bayes

and you don't have to add --dbpath