User Tools

Site Tools


How can I enable SpamAssassin on all cPanel accounts?


The "Apache SpamAssassin: Forced Global ON" option in WHM's Exim Configuration manager does not actually enable SpamAssassin the way you think it does. It creates the SpamAssassin module/option in the cPanel accounts, however if no configurations are set by the end user it's not really doing any good.

The article will cover how to enable SpamAssassin for every cPanel account account on your server with a few steps.

This article requires common knowledge of SSH / Terminal usage.

Enable SpamAssassin on all cPanel accounts

  • Log in to your server via SSH terminal as the root user.
  • Make sure the Global SpamAssassin Enable file exists, otherwise create it.
  touch /etc/global_spamassassin_enable
  • Create a 'default' or 'blanket' configuration for user preferences. Reference1) SA Configuration Manual for specifics on creating configuration files. For this example, we're using a simple configuration containing the rule "required_score 3". The default configuration file will be located in /root/support/spamassassin/
  touch /root/support/spamassassin/user_prefs && echo "required_score 3" >> /root/support/spamassassin/user_prefs
  • Once that's completed, continue with these loops to create the proper files/folders.
    • Create the "enable" files for each user:
  for i in `cat /etc/trueuserdomains | cut -d: -d' ' -f2-` ;do mkdir /home/$i/.spamassassin && touch /home/$i/.spamassassinenable ;done
  • Copy the default configuration we created in step 3 to all cPanel accounts:
  for i in `cat /etc/trueuserdomains | cut -d: -d' ' -f2-` ;do cp /root/support/spamassassin/user_prefs /home/$i/.spamassassin/ ;done
  • Correct the permissions and ownership of the files/folders just created:
  for i in `cat /etc/trueuserdomains | cut -d: -d' ' -f2-` ;do chown $i:$i /home/$i/.spamassassinenable && chown -R $i:$i /home/$i/.spamassassin ;done
  • That's it! All cPanel accounts have SpamAssassin enabled with user preferences.
control-panels/cpanel-whm/how-can-i-enable-spamassassin-on-all-cpanel-accounts.txt · Last modified: 2020/06/15 10:17 by Karson N.