Spam Assassin training?

Discussion in 'Server Operation' started by WhitcombeRD, Dec 18, 2020.

  1. WhitcombeRD

    WhitcombeRD Member

    Im running Buster / ispconfig 3.2.1 via "perfect server" setup ( )

    My issue is with SpamAssassin - it doesnt seem to be learning from the junk mails. I *think* it might be related to the root vs amavis user but im not sure.
    My /etc/spamassassin/ contains the line:-
    bayes_path /var/lib/amavis/.spamassassin/bayes
    As a trial i have mails in the junk folder and have tried learning using sa-learn both as root and user amavis.
    Running as user amavis i get this:-

    sudo -u amavis /usr/bin/sa-learn --spam /var/vmail/*/*/*/.Junk/*/*
    Learned tokens from 0 message(s) (0 message(s) examined)​
    In other words, it always says learned 0 messages and 0 messages examined.
    If i try the same command as root i get:-
    sudo /usr/bin/sa-learn --spam /var/vmail/*/*/*/.Junk/*/*
    Learned tokens from 40 message(s) (43 message(s) examined)
    So it sees the messages there and learns.
    The issue i think is learning as root is updating the tokens in the root directly not the amavis declared in
    This also means whatever cronjob is setup to run and auto learn seems to run as amavis user and therefore doesnt learn.

    Any idea how i can fix this to get sa to learn, store and use tokens? At the moment ive got a lot of identical spam getting through to all mailboxes that it just wont learn.
  2. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    The amavis user doesn't have permission to read mail files, only vmail and root do. I have used bindfs to mount training directories and remap user IDs so that amavis can read them; another option might be to add the amavis user to the vmail group for training and remove again when done (add those commands to your training script).
  3. WhitcombeRD

    WhitcombeRD Member

    Cheers - as a quick test adding to group vmail doesnt seem to work or change anything (maybe 700 permissions on vmail?).

Share This Page