• 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

Changing anti-spam and anti-virus for all accounts at once in SSH?

HHawk

Regular Pleskian
I did a search and came up with the following posted by IgorG and I quote:

For mass enabling antispam or antivirus for all emails you can use following scripts:

# for i in `mysql -uadmin -p\`cat /etc/psa/.psa.shadow\` psa -Ns -e "select concat(mail.mail_name,\"@\",domains.name) as address from mail,domains,accounts where mail.dom_id=domains.id and mail.account_id=accounts.id order by address"`; do /usr/local/psa/bin/spamassassin -u $i -status true; done

# for i in `mysql -uadmin -p\`cat /etc/psa/.psa.shadow\` psa -Ns -e "select concat(mail.mail_name,\"@\",domains.name) as address from mail,domains,accounts where mail.dom_id=domains.id and mail.account_id=accounts.id order by address"`; do /usr/local/psa/bin/mail -u $i -antivirus inout; done

First; this still works with Plesk 12.5 as well, right?

And how would I enable anti-spam (using the above) and set all emailaccounts to "Move spam to the Spam folder" (move)? I don't dare to fool around myself before I mess up things to be honest.

Also I want the anti-virus to be set to scan only incoming email (in) for all emailaccounts.

Thanks in advance for your help and advice.

Regards
 
Hello HHawk,

Regarding your question about enable anti-spam and "Move spam to the Spam folder" for all the e-mail accounts, the solution is:

mysql -uadmin -p`cat /etc/psa/.psa.shadow ` -Dpsa -Ne"SELECT CONCAT(mail_name,'@',name) FROM mail,domains WHERE dom_id=domains.id AND postbox='true';"|while read i;do /usr/local/psa/bin/spamassassin -u $i -status true -action move -hits 6;done

Best regards,
Horacio Stolovitzky
 
Wow thanks HoracioS!

One final question though. With the SSH command you gave me, how do I add (as an example) the following emailaddresses to the white-list: *@firstdomain.com and *@seconddomain.com?

Would it be this:

mysql -uadmin -p`cat /etc/psa/.psa.shadow ` -Dpsa -Ne"SELECT CONCAT(mail_name,'@',name) FROM mail,domains WHERE dom_id=domains.id AND postbox='true';"|while read i;do /usr/local/psa/bin/spamassassin -u $i -status true -action move -hits 6 -whitelist add:*@firstdomain.com,*@seconddomain.com;done

Or is that incorrect?

Or is adding these emailaddresses under "Tools & Settings" >> "Spam Filter" >> "White List" be enough? And therefor making it unnecessary to do it with the SSH command as shown above (in other words override it)?

Thanks once again in advace for your time and answer!
 
Much of that you do with utilities from /usr/local/psa/bin/ directory have the same effect when you do it from Plesk interface.
In you sample it doesn't matter how you will add emails to whitelist - through the command line command or GUI.
 
So if I add the emailaddresses to the "Tools & Settings" >> "Spam Filter" >> "White List" it will apply anyways for all hostingaccounts and therefor emailaccounts server-wide?
Awesome. :)
 
Back
Top