The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to Enable Auto Delete Spam for all accounts ?

Discussion in 'E-mail Discussions' started by renatoandrade, Nov 7, 2014.

  1. renatoandrade

    renatoandrade Member

    Joined:
    Feb 20, 2014
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    How to Enable Auto Delete Spam for all accounts ?

    Is there any way to do this in WHM or through SSH?
     
  2. jayharland

    jayharland Member

    Joined:
    Apr 18, 2014
    Messages:
    24
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Well one way to do it would be to set up filters that discard emails they catch (such as spam) but that's not recommended. Another way would be to tell Spamassassin to discard spam emails it catches but that's not recommended either. You could create a spam@your-domain.com email and redirect everything there at least until you get the filters/settings configured a way you like them. That way you don't risk auto-deleting legit emails flagged as spam.

    I'm no pro but I've been fighting spam on my server for some time now using spamassassin and account level filters. We redirect everything to a spam vault and keep it around in case we need to search it for possible false positives.
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,831
    Likes Received:
    672
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    You may want to consider utilizing a global filter for Exim. The global filter file is located at:

    Code:
    /etc/cpanel_exim_system_filter
    You can copy this file to a new file and configure Exim to use the custom filter file via the following option under the "Filters" tab in "WHM Home » Service Configuration » Exim Configuration Manager":

    "System Filter File"

    Thank you.
     
  4. renatoandrade

    renatoandrade Member

    Joined:
    Feb 20, 2014
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hello after a long time I found out how to auto delete for all accounts, I will share here because maybe some users may have last the same as I passed, below steps:

    First you need to create 3 files with content in them, I recommend also create a folder to store the files, in my case I created the folder /spmass and access folder

    Code:
    mkdir /spmass ; cd /spmass
    
    First create three files with the names and permissions:

    Use the nano editor to create the files:
    .filter
    filter.cache
    filter.yaml

    Permissions 0644

    Below is a step by step:

    Then edit each and place the contents as follows:

    File .filter :
    Code:
    nano .filter
    
    Paste content:
    Code:
    
    $h_X-Spam-Bar: contains "+++++"+++++++/dev/null
    
    

    File filter.cache :
    Code:
    nano filter.cache
    
    Paste content:
    Code:
    
    pst0
    -Generated Apache SpamAssassin™ Discard Rule
    filtername
       /dev/nulldest
    saveactionactions
    $h_X-Spam-Bar:part
    containsmatch
    +++++val
    
    

    File filter.yaml :
    Code:
    nano filter.yaml
    
    paste content:
    Code:
    
    ---
    filter:
      -
      actions:
      -
      action: save
      dest: /dev/null
      filtername: Generated Apache SpamAssassin™ Discard Rule
      rules:
      -
      match: contains
      opt: or
      part: "$h_X-Spam-Bar:"
      val: +++++
    
    

    Change permissions:
    Code:
    chmod -v 0644 filter* ; chmod -v 0644 .filter
    

    Done all the above procedures is only run the following command:
    Code:
    for user in `ls /var/cpanel/users/` ; do rsync -v /spmass/.filter /home/$user/ ; chown -v $user:$user /home/$user/.filter ; rsync -v /spmass/filter.* /home/$user/.cpanel/ ; chown -v $user:$user /home/$user/.cpanel/filter* ; done
    

    Restart Exim:
    Code:
    service exim restart
    
    Ready! Now Spam Auto-Delete feature automatically deletes messages enabled! for all domains and existing accounts in cpanel, if you need to do this for future domains created on the server, simply place the command in a cron job.

    I hope this helps.
     
    #4 renatoandrade, Oct 7, 2015
    Last edited: Oct 7, 2015
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,831
    Likes Received:
    672
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  6. renatoandrade

    renatoandrade Member

    Joined:
    Feb 20, 2014
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    This setting works with the Force Global On option spamassassin, it automatically deletes those spam, greatly decreases the spam rate in inboxes, but I only use this option because I turn off the Box Trapper.
     
Loading...

Share This Page