ISPConfig, IMAP and sa-learn (spamassasin)?

Discussion in 'Server Operation' started by eldaria, Dec 27, 2006.

  1. eldaria

    eldaria New Member


    I'm using ISPConfig with the Ubuntu setup, and would like to know how I can train the Spamassasin filter since it catches hardly anything at the moment.
    I get 400+ Spam mails per day and it is really getting on my nervs. :eek:

    I use mainly IMAP with Kontakt/Kmail on client side.
    This to be able to have server based mail folders to also enable webmail.
    On the client side I have sorted spam mail into a sub folder, and would like to train spamassasin with those mails.
    So I logged on to the server and go to the Maildir folder, and can only find mail in the 'cur' folder.
    But they are not sorted into sub folder but are all in one folder with very odd and sometimes very long names.
    Here is a couple of examples:
    Hostname part replaced with:
    How can I use sa-learn on this, when I don't knoa what mail is in what folder on IMAP?

    A feature that would be nice that I had on Exchange server, if Spamassasin identifies that a mail is Spam, to move it to a certain folder.
    This is not that important but more a convenience.

    And is there a way to teach Spamassasin on the server from client side?
    So when I click the Spam or Ham button in Kmail it will signal Spamassasin on server side?
    Well I guess with some advanced scripting but perhaps there is an easy way.
    This is not that important either as long as first question is working.

  2. falko

    falko Super Moderator ISPConfig Developer

    You could upload the mails to the server (e.g. with FTP) and then use sa-learn to train SpamAssassin.
  3. eldaria

    eldaria New Member

    Yes I guess that would work If I sorted mails to local folders.

    Was more thinking if there was a way of the IMAP server detecting if a mail was moved to a certain sub folder, (On the IMAP server).

    Well will sort locally for now. :)
  4. falko

    falko Super Moderator ISPConfig Developer

    You could create a spam folder with your IMAP client and move all spam mails into that folder. And then you use sa-learn to learn from that folder.
  5. Ben

    Ben ISPConfig Developer ISPConfig Developer

    Will it help to set up a spamtraining mailadress and forward all spam mail to this box and try sa-learn with this?
  6. eldaria

    eldaria New Member

    I looked, but when I create folders with the IMAP client, they are not created as a folder on the filesystem on the server.
    On the server all mails are still in one folder( ~/Maildir/cur/), but when I log in with a mail client like the Roundcube webmail client, it will see the folders I created and the mails I moved into there.

    I was thinking about that solution after reading some of the posts here on the forum, the problem with that solution is to mark messages that are not spam but was detected as such.

    I folowed falko's first suggestion and created now 2 local folders, since creating a local folder will actually create a folder on the file system. Then when I mark as spam manually, they get sorted to this folder, while mail already detected as being spam are automatically sorted to a different folder. Then if any of those mails are wrongly detected as spam, I have a button where it will move it back to In-box, and create a copy in a 'Ham' Folder.
    Now I can copy these files to the server and run sa-learn on them.

    I'm also looking into the fact that spamassasin can store info in a SQL database, so was thinking about making client and server use the same database, so a change made on client will be used by Spamassasin on server.
    But not sure how to get Spamassasin to use an SQL server yet. ;-)
  7. falko

    falko Super Moderator ISPConfig Developer

    The problem with this is that as soon as you forward the mails, their headers get modified, so sa-learn wouldn't learn from the original mails... :(
  8. eldaria

    eldaria New Member

    Do I need to run sa-learn with a specific user or is the database global?

    Like: sa-learn -u web1_user1 --spam <message>

    The reason I'm asking is that so far I have been running it without specifying a user, and noticed in the help it says it will then use the default user from runtime environment.

    But kind of realized that my mails are arriving on a different user that was set up by isp_config.

    Last edited: Jan 6, 2007
  9. falko

    falko Super Moderator ISPConfig Developer

    The database is global, so I'd run sa-learn as root.
  10. RicochetPeter

    RicochetPeter Member

    Hallo Falko,

    das habe ich soeben mal getan, hier meine Kommandozeile:

    [email protected]:/var/www/www.[].de/Maildir/.Spam/cur# /home/admispconfig/ispconfig/tools/spamassassin/usr/bin/sa-learn --spam *
    Das Verzeichnis, in dem ich gestartet habe, ist ein per IMAP-Client angelegter Folder, in dem eben ganz viele Spam-nachrichten liegen. Was sa-learn getan hat, war, die Dateien
    /root/.spamassassin/bayes_seen und
    zu aktualisieren (bzw zu erstellen, es gab sie vorher noch nicht).

    Wird der Spamassassin, der bei Ankunft einer Mail gestartet wird, diese Dateien auswerten?
  11. falko

    falko Super Moderator ISPConfig Developer

    English, please!

    I think it creates a database for the user under that you run the sa-learn command, not a global database. i'm not sure how to do this right now. Please take a look at
    /home/admispconfig/ispconfig/tools/spamassassin/usr/bin/sa-learn --help
    man sa-learn
  12. RicochetPeter

    RicochetPeter Member

    The better question at this place is where the spamassassin that's being called upon incoming mail would like to have its bayes db located, so that it can be put there -even manually- after running sa-learn?
  13. brengo

    brengo New Member

    jep - that's a question I'm also interested in (ehere's the global bayes.db?)

Share This Page