@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?
See here:
http://www.roundcubeforum.net/7-third-party-contributions/46-api-based-plugins/5957-markasjunk2-sa-learn-problem.html
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.
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.
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 + }
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.
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...
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.
OK thanks, but could you help me with the main problem with sa-learn?
sorry i dont really know anything about sa-learn
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
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.
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.
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'
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/bayesand you don't have to add --dbpath
but why I can use sa-learn from shell normally? without --dbpath
I think its becuse by default sa-learn uses the home dir of the user it is running under and your shell user account probably has a lot more power to write to places than the user the web server runs as.
Hi guys,
I have markasjuck2 configured to use cmd_learn and markasjunk2 debugging on. When I view the markasjunk2 log, the first line shows the command but the second line just shows NULL instead of the 'Learned' line.
If I run the same command in the log on the command line, SA learns the email as expected.
I would be grateful if anyone has any thoughts.
Many thanks.