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.

Spam box autodeleter Addon

Discussion in 'User Experience' started by Juanra, Mar 28, 2004.

  1. Juanra

    Juanra Well-Known Member

    Joined:
    Sep 22, 2001
    Messages:
    777
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Spain
    I've just finished writing the first release of the CPMSpamBoxes addon module. Users can choose if they want their spam boxes autodeleted or not. If they do, the autodeleter script will send each account owner a daily report containing the date, sender and subject of all deleted messages. That way one still can figure out if some legitimate email might be lost.

    Today I checked my spam box for the first time since February 10 and there were like 4000 spam messages in it... I will surely find this useful :D

    Beta release, installation notes enclosed. Your feedback is appreciated:

    http://www.cpanelmodules.com/docs/CPMSpamBoxes.pdf
    http://www.cpanelmodules.com/download/CPMSpamBoxes.tar.gz
     
    #1 Juanra, Mar 28, 2004
    Last edited: Mar 28, 2004
  2. equens

    equens Well-Known Member

    Joined:
    Feb 8, 2002
    Messages:
    270
    Likes Received:
    0
    Trophy Points:
    16
    Can you explain how this module works? Is "Spam box autodeleter Addon" deleting mesages from the spam box activated in Spam Assasin options. At this moment, I redirect all spam to spam@mydomain.com and I check these messages with PopTray one or twice every day.

    Hola Juanra, me parece un modulo muy interesante y que puede ayudar a conocer la magnitud y la efectividad de la lucha contra el spam, además de poder confirmar si hemos eliminado algún mensaje importante.
     
  3. Juanra

    Juanra Well-Known Member

    Joined:
    Sep 22, 2001
    Messages:
    777
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Spain
    This is more geared toward the users who never check their spam box or don't even know it exists, so their system quota isn't reached because of the spam.

    The current version deletes the spamboxes and emails the report, but I want to it to be configurable on a per user basis and give the possibility to retrieve legitimate email before it gets deleted.

    In general you need to modify your cpanel theme to add the new functions, but if you're using custom themes that shouldn't be too worrying.

    Si quieres instalarlo y necesitas ayuda mándame un email y lo miramos.
     
  4. wimp

    wimp Well-Known Member

    Joined:
    Jul 13, 2002
    Messages:
    301
    Likes Received:
    0
    Trophy Points:
    16
    greate idea!
    Is there any way i can use this as server administrator to delet all spam boxes for all customers?
    is ther any way to config the script in that way?

    thanks a lot
     
  5. comprock

    comprock Member

    Joined:
    Nov 6, 2003
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    aging?

    Thank you for the script.

    Is there a means to add date deletions? I'm not a Perl guy, but simply truncating the spam file seems overkill. I'd like to kill the 1,000 or two spams that came in the previous week, but allow folks to still check for this weeks spam for false positives.

    Cheers,

    Michael
     
  6. comprock

    comprock Member

    Joined:
    Nov 6, 2003
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    file setup, changes

    I got the primary script working, but made a few minor changes to get it working slicker.

    To add the script into your x themes edit your /usr/local/cpanel/base/frontend/x/mail/email.html by adding the following. I placed mine below Spam Assassin.

    Code:
    <cpanelfeature cpanelmodules.com_autodeletespamboxes>
     <tr valign="middle">
        <td><img src="../images/arrow-let.gif"></td>
        <td height="25"><font face="Arial"> <a href="autodeletespambox.html"><cpanel langprint="MENUSpamAutoDelete"></a></font>
        </td>
      </tr>
    </cpanelfeature>
    
    Add the language tag to your /usr/local/cpanel/lang/english or other localization file. I added mine below MENUSpamAssassin.

    Code:
    MENUSpamAutoDelete=Auto-Delete Spam Folder
    Next, to give your WHM Feature Manger a bit more meaning and enable feature on/off; edit /usr/local/cpanel/whostmgr/addonsfeatures/cpanelmodules.com. Replace the other "cpanelmodules.com_autodeletespamboxes" line with this one. The original tries to make a link where none is allowed. Additionally, it prevents the feature on/off capability from working in feature lists.

    Code:
    cpanelmodules.com_autodeletespamboxes:Spam Folder Auto-Delete
    For the actual autodeletespam form page, create /usr/local/cpanel/base/frontend/x/mail/autodeletespambox.html and add the following.

    Code:
    <cpanel setvar="headerimg=../images/mailmenu.gif">
    <cpanel setvar="dprefix=../">
    <cpanel include="../stdheader.html">
    
    <cpanel CPMSpamBoxes="CheckStatus()">
    <form action="autodeletespambox.html">
    
      <input type="radio"
             name="autodelete"
             value="yes"
      <cpanelif $CONF{'CPMSpamBoxes_autodelete'}>
      checked="checked"
      </cpanelif>
      /> Auto-delete spam boxes
    
      <br />
      
      <input type="radio"
             name="autodelete"
             value="no"
      <cpanelif !$CONF{'CPMSpamBoxes_autodelete'}>
      checked="checked"
      </cpanelif>
      /> Don't auto-delete spam boxes
    
      <br />
    
      <input type="submit"
             value="Modify auto-delete configuration" />
    
    </form>
    
    <cpanel CPMSpamBoxes="Autodelete(status)">
    <cpanel CPMSpamBoxes="Autodelete($FORM{'autodelete'})">
    
    <center>
    <b>[</b>&nbsp;<a href = "email.html"><cpanel langprint="Goback"></a>&nbsp;<b>]</b>
    </center>
    <cpanel include="../stdfooter.html">
    
    I hope this helps others.

    Cheers,

    Michael
     
    #6 comprock, May 17, 2004
    Last edited: May 17, 2004
  7. comprock

    comprock Member

    Joined:
    Nov 6, 2003
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
  8. comprock

    comprock Member

    Joined:
    Nov 6, 2003
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    crontab archivemail

    While a flexible date option is in the works, I decided to just purge all spam folder content older than 7-days. Given that already 16,000 e-mails flow through my server each week killing off spam on a rolling-weekly basis would help greatly with disk space for folks who check spam folders or not.

    Install archivemail mentioned above, then create a root crontab entry by calling "crontab -e" as root.

    Code:
    12 3 * * * /usr/bin/find /home2/ -name spam -exec /usr/bin/archivemail --delete --days=7 {} \;
    or

    Create an /etc/cron.daily/deletespam script with the above in it.

    My cpanel user accounts reside in /home2 versus /home hence find being restricted to that directory only. Since I don't run other mail software with spam filtering outside of cpanel, I'm not worried about users in /home.

    Thoughts?

    Michael


    PS: For kicks I ran the above find from the command line and whacked over 30,000 old spam messages for the past few months in 15 minutes. Too bad, there's still 4,000 a week in one account.
     
  9. wimp

    wimp Well-Known Member

    Joined:
    Jul 13, 2002
    Messages:
    301
    Likes Received:
    0
    Trophy Points:
    16
    wow the story with archivemail sounds good..
    however i not a fried of contabs etc. Can you please tell me how to create that contab to delete spam mails every 7 days ?
    I have accounts in /home.


    Thanks a lot
     
  10. comprock

    comprock Member

    Joined:
    Nov 6, 2003
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    wimp,

    Glad this has helped somebody.

    I moved my crontab entry out and replaced it with a file in /etc/cron.daily instead. That way you can just let it run when the rest of your daily scripts fire off. No explanations below, just what is.

    Code:
    cannon@peipei:~ $ cd /etc/cron.daily/
    cannon@peipei:/etc/cron.daily $ ls
    00-logwatch@         fixcvsperms*  logrotate*        rm_backup*     sysbk*
    chkrootkit*          fixquotas*    makewhatis.cron*  rpm*           tmpwatch*
    delete-spam-folder*  fw*           purge-spam*       slocate.cron*
    cannon@peipei:/etc/cron.daily $ cat purge-spam 
    #!/bin/sh
    
    # Purge spam older than 7 days
    #
    # @author Michael Cannon <michael@cannonbose.com>
    # @version $Id:$
    
    /usr/bin/find /home2/ -name spam -type f \
            -exec /usr/bin/archivemail --delete --days=7 {} \;
    cannon@peipei:/etc/cron.daily $ ll purge-spam 
    -rwxr-xr-x    1 root     root          207 May 19 09:34 purge-spam*
    cannon@peipei:/etc/cron.daily $ cat delete-spam-folder 
    #!/bin/sh
    
    # Delete spam folder entirely if client says so
    #
    # @author Michael Cannon <michael@cannonbose.com>
    # @version $Id:$
    
    /usr/local/cpanel/bin/cpanelmodules.com/CPMSpamBoxes/cleanspamboxes
    cannon@peipei:/etc/cron.daily $ ll delete-spam-folder 
    -rwxr-xr-x    1 root     root          197 May 19 09:35 delete-spam-folder*
    cannon@peipei:/etc/cron.daily $  
    
    So, in short purge-spam uses archivemail to delete spam older than 7 days while delete-spam-folder kills off the spam folder entirely everyday if an account holder has chosen to do so.

    Have fun,

    Michael
     
  11. comprock

    comprock Member

    Joined:
    Nov 6, 2003
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    For making a user crontab follow the below sample.

    Code:
    cannon@peipei:~ $ sudo -s
    Password:
    root@peipei:~ # crontab -e
    crontab: no changes made to crontab
    root@peipei:~ # exit
    exit
    cannon@peipei:~ $  
    
    In this case a crontab is created for the root user. If the user was george, then george would have a new crontab. Do a 'man crontab' to explain the different options.

    Cheers,

    Michael
     
  12. wimp

    wimp Well-Known Member

    Joined:
    Jul 13, 2002
    Messages:
    301
    Likes Received:
    0
    Trophy Points:
    16
    ok i will try this out.

    Thank you!
    :)
     
  13. wimp

    wimp Well-Known Member

    Joined:
    Jul 13, 2002
    Messages:
    301
    Likes Received:
    0
    Trophy Points:
    16
    do i need to install the API calls? I am using RVSkin and not sure if this will work. What i like to do is simple: just delet all mails inside the spambox to not fill up the customers webspace. I dont like to have any button inside the control panel for customer. The spambox should be cleaned automatically by the system every 7 days.

    Just an additional question: i woul like to clean All customers spambox on the server. Can i do this with a cron?

    thanks
     
    #13 wimp, May 30, 2004
    Last edited: May 30, 2004
  14. comprock

    comprock Member

    Joined:
    Nov 6, 2003
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    wimp,

    If you just pull down archivemail and run the cron.daily script purge-spam, that'll remove any spam older than 7 days automatically from the users spam folders.

    No need to do the delete-spam script if you don't want it. I just found that first and put it together. Then while doing so, I found what I like better, archivemail.

    Michael
     
  15. beerguy

    beerguy Member

    Joined:
    Apr 8, 2002
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    I was just about to post a message that said, "Has anyone come up with a way to delete the spam that goes into the spambox via Spam Assassin?" When I discovered this thread! This looks exactly like what I need.

    My question: Is this ready enough for those of us with more modest cpanel sand unix skills...and are the links atop this thread the latest versions.

    Thank you again for figuring this one out.

    Jamie
     
  16. wimp

    wimp Well-Known Member

    Joined:
    Jul 13, 2002
    Messages:
    301
    Likes Received:
    0
    Trophy Points:
    16
    i not sure how to install ahcivemail.. i read and read again the documention that comes with archivmail but could not finde any details on how to configure. Now, have i to config. the script or can i use it as it is?? Also where will it be installed? and if it create problems, can I uninstall it?


    thanks a lot
     
  17. wimp

    wimp Well-Known Member

    Joined:
    Jul 13, 2002
    Messages:
    301
    Likes Received:
    0
    Trophy Points:
    16
  18. t9clkclnr

    t9clkclnr Well-Known Member

    Joined:
    Jun 11, 2004
    Messages:
    254
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Southern California
    I had already posted about this and ten minutes later found this thread

    I will be trying this and posting feedback.

    Much appreciation
     
Loading...

Share This Page