Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

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

Discussion in 'E-mail Discussion' started by crazyaboutlinux, Sep 14, 2011.

  1. crazyaboutlinux

    crazyaboutlinux Well-Known Member

    Joined:
    Nov 3, 2007
    Messages:
    939
    Likes Received:
    0
    Trophy Points:
    66
    Turn on SpamAssassin™ for all accounts (i.e. with yes option to disable).
     
  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,608
    Likes Received:
    32
    Trophy Points:
    238
    Location:
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. crazyaboutlinux

    crazyaboutlinux Well-Known Member

    Joined:
    Nov 3, 2007
    Messages:
    939
    Likes Received:
    0
    Trophy Points:
    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 ??
     
  4. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,608
    Likes Received:
    32
    Trophy Points:
    238
    Location:
    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
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. cPanelNick

    cPanelNick Administrator
    Staff Member

    Joined:
    Mar 9, 2015
    Messages:
    3,483
    Likes Received:
    31
    Trophy Points:
    158
    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.
     
  6. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,608
    Likes Received:
    32
    Trophy Points:
    238
    Location:
    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:

    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice