• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

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

T

Traged1

Guest
Is there any way to turn Spam filtering ON for ALL mailboxes on a server?
 
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.
 
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.
 
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
 
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?
 
PLESK should turn on spam filtering by defualt when a mailbox is created, that would be nice.
 
/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
 
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.
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.
 
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.
 
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".
 
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 [email protected] -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
 
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.
 
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?
 
Yes thanks, but...

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


Bart
 
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.
 
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.
 
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 = '[email protected]';

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.
 
Back
Top