• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

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