Author Topic: markasjunk2  (Read 14232 times)

Offline dziobak

  • Full Member
  • ***
  • Posts: 184
markasjunk2
« on: April 08, 2010, 09:19:20 AM »
@JohnDoh

I have problem with markasjunk2. Every message that I'm marking is not learned
Code: [Select]
[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
Code: [Select]
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?


Offline dziobak

  • Full Member
  • ***
  • Posts: 184
markasjunk2
« Reply #2 on: April 09, 2010, 02:47:54 AM »
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.
« Last Edit: April 09, 2010, 03:03:33 AM by dziobak »

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,855
markasjunk2
« Reply #3 on: April 09, 2010, 03:20:27 AM »
if you want to see the file its creating then try commenting out
Code: [Select]
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…

Offline dziobak

  • Full Member
  • ***
  • Posts: 184
markasjunk2
« Reply #4 on: April 09, 2010, 04:28:40 AM »
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 'test@exemple.com' but 'test'), so I have added some lines in cmd_learn.php and change the command to
Code: [Select]
/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 +   }

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,855
markasjunk2
« Reply #5 on: April 09, 2010, 04:44:32 AM »
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…

Offline dziobak

  • Full Member
  • ***
  • Posts: 184
markasjunk2
« Reply #6 on: April 09, 2010, 05:00:02 AM »
what would happen when I login to roundcube as test@example.com? the session user name will be test@example.com but i want to have only test. So when I login as test@example.com 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...
« Last Edit: April 09, 2010, 05:06:04 AM by dziobak »

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,855
markasjunk2
« Reply #7 on: April 09, 2010, 08:04:08 AM »
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…

Offline dziobak

  • Full Member
  • ***
  • Posts: 184
markasjunk2
« Reply #8 on: April 09, 2010, 08:31:11 AM »
OK thanks, but could you help me with the main problem with sa-learn?

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,855
markasjunk2
« Reply #9 on: April 10, 2010, 07:58:51 AM »
sorry i dont really know anything about sa-learn
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…

Offline Martian

  • Jr. Member
  • **
  • Posts: 35
markasjunk2
« Reply #10 on: April 10, 2010, 10:40:15 AM »
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

Offline dziobak

  • Full Member
  • ***
  • Posts: 184
markasjunk2
« Reply #11 on: April 10, 2010, 11:33:19 AM »
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
Code: [Select]
'/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
Code: [Select]
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.

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,855
markasjunk2
« Reply #12 on: April 10, 2010, 02:28:17 PM »
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…

Offline dziobak

  • Full Member
  • ***
  • Posts: 184
markasjunk2
« Reply #13 on: April 10, 2010, 03:44:19 PM »
Quote from: JohnDoh;26722
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.


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 :-)


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

Offline fritz001

  • Jr. Member
  • **
  • Posts: 22
markasjunk2
« Reply #14 on: April 10, 2010, 11:45:01 PM »
Quote from: dziobak;26723
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 :-)


Code: [Select]
'/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