how to Turn on SpamAssassi for all accounts (i.e. with yes option to disab

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
41
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
Re: how to Turn on SpamAssassi for all accounts (i.e. with yes option to di

So you want to turn it on globally but still allow users to disable it if they want to do so? WHM > Exim Configuration Editor > SpamAssassin™: Forced Global ON option, but this would then not allow the users to disable it. There is not currently an option to globally enable it on all accounts but still allow disabling it.
 

crazyaboutlinux

Well-Known Member
Nov 3, 2007
939
1
66
Re: how to Turn on SpamAssassi for all accounts (i.e. with yes option to di

So bad:(
Is it possible to this from SSH ??
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
41
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
Re: how to Turn on SpamAssassi for all accounts (i.e. with yes option to di

For SpamAssassin to be enabled, you'd have to add the file .spamassassinenable to /home/username, then add the folder .spamassassin to /home/username with a user_prefs file in it. You could enable it on one account to see the file contents for the /home/username/.spamassassin/user_prefs file.

You could copy that file to /root/spamassassin/user_prefs then create a postwwwacct script for that to enable when the user account is created:

Code:
mkdir /root/spamassassin
cp /home/username/.spamassassin/user_prefs /root/spamassassin
Above, replace username with the cPanel username in that above command only. Any other instances in the lines below should not be replaced but entered exactly as input.

Code:
vi /usr/local/cpanel/scripts/postwwwacct
In that file put the following:

Code:
#!/usr/bin/perl

my %OPTS = @ARGV;
$ENV{USER} = “$OPTS{‘user’}”;
system q(mkdir /home/$USER/.spamassassin);
system q(touch /home/$USER/.spamassassinenable);
system q(cp /root/spamassassin/user_prefs /home/$USER/.spamassassin/);
system q(chown $USER:$USER /home/$USER/.spamassassinenable);
system q(chown -R $USER:$USER /home/$USER/.spamassassin);
system q(chmod 700 /home/$USER/.spamassassin);
After creating that file, ensure it can execute:

Code:
chmod +x /usr/local/cpanel/scripts/postwwwacct
I tested the above, and it does work for account creation. As for enabling this on all existing accounts, you could run the following commands:

Code:
for i in `cat /etc/trueuserdomains | cut -d: -d' ' -f2-` ;do mkdir /home/$i/.spamassassin && touch /home/$i/.spamassassinenable ;done
for i in `cat /etc/trueuserdomains | cut -d: -d' ' -f2-` ;do cp /root/spamassassin/user_prefs /home/$i/.spamassassin/ ;done
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
 

cPanelNick

Administrator
Staff member
Mar 9, 2015
3,481
35
208
cPanel Access Level
DataCenter Provider
Re: how to Turn on SpamAssassi for all accounts (i.e. with yes option to di

Code:
touch /etc/global_spamassassin_enable
This should take care of it.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
41
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
Re: how to Turn on SpamAssassi for all accounts (i.e. with yes option to di

By touching that file, it will not allow the user to disable SpamAssassin in cPanel, which was a requirement by the poster per the original request:

Turn on SpamAssassin™ for all accounts (i.e. with yes option to disable).
He would like to enable it for all accounts that exist, then to enable it on all accounts that are created, but still allow those users to turn it off after account creation or enabling if they so desire in cPanel > SpamAssassin area. The /etc/global_spamassassin_enable file forces it to be globally on without the option in cPanel > SpamAssassin area to disable it per user.