1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice

How to turn Spam filtering ON for ALL mailboxes on a server?

Discussion in 'Plesk for Linux - 8.x and Older' started by Traged1, Sep 22, 2005.

  1. Traged1

    Traged1 Guest

    0
     
    Is there any way to turn Spam filtering ON for ALL mailboxes on a server?
     
  2. sieb@

    sieb@ Guest

    0
     
    You mean all at once? no, its a per account option as you create the accounts. You can either go into each account and set it by hand, or figure out some fancy mysql command to edit all the tables at once.
     
  3. Traged1

    Traged1 Guest

    0
     
    Thats what I was thinking, a mysql command, I'll have to poke into the DB to see which field and table the mailbox info is stored in.
     
  4. rvdmeer

    rvdmeer Guest

    0
     
    Hi,

    [root@ptest ronald]# /usr/local/psa/admin/sbin/mchk --help
    Usage: mchk [OPTION]
    Restore settings for all mailboxes.

    --without-spam
    restore all settings except for SpamAssassin configuration
    --with-spam
    restore all settings
    --spam-only
    restore only SpamAssassin settings

    I hope this helps
     
  5. Traged1

    Traged1 Guest

    0
     
    Thanks, but that will only restore them if they were already turned on.

    I am looking for a way to turn on all the email box's spam filtering which are on the server. Since there are over 400 domains and well over 1000 email addresses on this server, I would say I don't want to do this by hand.

    I have figuired out that the spam filter settings are stored in the psa database table "sa_conf"

    Now I just need to figuire out how to loop through all the email addresses which reside on the server and add them to this table. Then I can run /usr/local/psa/admin/sbin/mchk --with-spam to get all the psa-spamassassin commands added to the mailbox .qmail files.

    Anyone got any idea's?
     
  6. Traged1

    Traged1 Guest

    0
     
    PLESK should turn on spam filtering by defualt when a mailbox is created, that would be nice.
     
  7. rvdmeer

    rvdmeer Guest

    0
     
    /usr/local/psa/admin/sbin/mchk -v

    Startup top and typ in top: cas1 (after that press enter) It will show you the processes with command options refresh every second. So you can see what is does and mchk -v will enable all the mailbox if i'm correct
     
  8. jamesyeeoc

    jamesyeeoc Guest

    0
     
    I don't use Plesk's SA module, so I'm not sure which Field you wish to change to what value, but here is an example which should be pretty straight forward to change the field and value to what you need:

    1. Login via SSH as root

    2. Login to mysql (mysql -uadmin -p<yourpassword> psa

    3. UPDATE sa_conf SET spam_action = 'save';
    (don't forget the ; on the end of the line!)

    or other examples:

    UPDATE sa_conf SET spam_action = 'delete';
    UPDATE sa_conf SET flt_enabled = 'both';
    UPDATE sa_conf SET flt_enabled = 'user';
    UPDATE sa_conf SET hits_required = '5';

    4. It should show you results something like:

    Query OK, 3000 rows affected (0.73 sec)
    Rows matched: 3000 Changed: 3000 Warnings: 0

    5. To exit mysql commandline, type quit and press enter.

    Disclaimer: Do backups! I am not responsible if your server breaks for any reason, especially typos on your part! This works on my servers, but I don't know enough about yours to make any assurances!

    Hope this helps.
     
  9. Traged1

    Traged1 Guest

    0
     
    But all the email addresses are not already in the sa_conf table yet?

    A UPDATE sa_conf SET spam_action = 'save' would only affect the email addresses which are already in the sa_conf table.

    I need to find a way to get all the email addresses which do not already have spam-filtering turned on, which means they are not yet listed in the sa_conf table, to be listed in the sa_conf table. If that makes any sense.
     
  10. jamesyeeoc

    jamesyeeoc Guest

    0
     
    The default values according to the 'Structure' of the table are as follows:

    Code:
    Field		Type				Default
    mailname	varchar(128)			null
    flt_enabled	enum('user','serv','both')	both
    rw_subject_tab	varchar(255)			***SPAM***
    hits_required	tinyint(3)			7
    spam_action	enum('delete','save')		save
    
    So unless they are not using the table's defaults, the only other thing I can recommend is using the Event Manager feature to run a short script to set it upon "New mail name created".
     
  11. bartje3

    bartje3 Guest

    0
     
    Hi,

    I don't think it is just the change of a database value, because for each mailbox where spam is enabled it adds also a line to the .qmail file of that mailname in /var/qmail/mailnames/domain.com/example/

    like: | if [ -z "$SA" ]; then export SA=1; /usr/local/psa/bin/psa-spamc -f -u info@domain.com -U /tmp/spamd_light.sock > spamcheck$$; /var/qmail/bin/qmail-local "$USER" "$HOME" "$LOCAL" "" "" "$HOST" "$SENDER" "$DEFAULT" < spamcheck$$; retval=$?; rm -f spamcheck$$; [ $retval = 0 ] && exit 99; exit $?; fi

    ...so, no way to do this "serverwide" (or you need a script) !

    I would be happy if SWSoft would add spam enabling to the groupoperations of the domains, but I guess this is already suggested.

    If you have a full list of all mailnames, you could use the command line utilities by running:

    /usr/local/psa/bin/spamassassin.sh -u mailname -status true

    for all mailnames :D (maybe you can get the mailaccounts list from the PSA db table "mail" ('mail_name'))

    Regards,
    Bart
     
  12. phoenixisp

    phoenixisp Silver Pleskian

    27
    57%
    Joined:
    Feb 2, 2002
    Messages:
    840
    Likes Received:
    0
    Tragid1 - a while back jimroe did an antivirus/spamassassin/Odeiavir how-to that had a script which added the .qmail enties that you are looking for. If memory serves me correctly, it was under Plesk 5.x.x. Maybe a search or PM to jimroe could help.
     
  13. Traged1

    Traged1 Guest

    0
     
    Thanks all,

    The reason I am doing this, is that I have been working on a new script which will be piped from the .qmail files.

    The script has two functions:

    It detects the presence of the psa-spamassassin settings in the .qmail files IE: "| if [ -z "$SA" ]; then export SA=1; /usr/local/psa/bin/psa-spamc" if it is present it will create a new .qmail file with the new pipe command to the spamcop reporter.

    The primary function of the script is to collect all the emails from the system which have been flagged as spam by SA, then it will teach bayes the spam token and report the spam to spamcop.

    Since the script rely's on the SA flagging it must be piped after the psa-spamassassin command in the .qmail file.

    The testing I have done, everything works, it will add the pipe command in the .qmail, and it does the reporting correctly, it will loop through all the .qmail files on the server. But it will only enable if the SA pipe exists. This is why I am trying to get all the currently existing mailboxes to have the SA enabled.

    However, I think I should be able to now to modify my script so that when it is checking the .qmail files for the SA pipe, if it is not present, I could add a sub-routine which will do /usr/local/psa/bin/spamassassin.sh -u mailname -status true. I think this will work, cool.

    If anyone is interested I can post the script or make it available for download?
     
  14. bartje3

    bartje3 Guest

    0
     
    Yes thanks, but...

    again SWSoft has saved the work of a developer ;-)


    Bart
     
  15. Traged1

    Traged1 Guest

    0
     
    As soon as I have it so that the script will turn on the Spam filtering automatically I will post a link to the script here. Should be in the next 24 hours or so.
     
  16. phoenixisp

    phoenixisp Silver Pleskian

    27
    57%
    Joined:
    Feb 2, 2002
    Messages:
    840
    Likes Received:
    0
    I for one am looking forward to it.
     
  17. Traged1

    Traged1 Guest

    0
     
    Yeah, it works.

    Since I couldn't get the list of email addresses from the psa database, as the full email address spans multiple tables, I decided to recreate the full email address by stuffing the filepath location to the .qmail file into an array and then simply recreating the full email address by accessing the correect array elements.

    The script now turns on spam filtering for all email addresses which are true mailboxes(not a redirect) where spam filtering is not already enabled.

    Currently the script only works through the command line, and I am now cleaning it up for cron usage.
     
  18. Traged1

    Traged1 Guest

    0
     
    OK, here is the install for the new scripts:

    First of all:

    Tested on RHEL3 with PLESK 7.5.4 ONLY.

    Tested for command line use only, not yet ready for cron.

    Download http://www.xtreme-host.com/dev/pub/report-spam.zip

    Unzip,

    Copy both files to /usr/local/bin/

    chown popuser : popuser report-spam.pl

    chmod 755 /usr/local/bin/report-spam.pl

    chmod 755 /usr/local/bin/insert-report-spam.cgi

    pico or vi /usr/local/bin/report-spam.pl

    **Place your spamcop submit address inside of the variable:
    my $spamcop = 'submit.F4WP1mqEpgY67keA@spam.spamcop.net';

    Run:
    /usr/local/bin/insert-report-spam.cgi

    The script will make a backup of the original .qmail files in the mailname folder.

    I suggest that you run the script at least twice to start, the first run will enable any mailboxes found to not have spam filtering enabled already, and then second run will add the report-spam pipe to the newly enabled mailbox .qmail files.
     
Loading...