• Sales Chat
    • My Account
    LOGICWEB
    • Hosting
      • Shared Hosting

        SSD + cPanel + CDN

        Reseller Hosting

        More Value & Performance

        VPS Hosting

        VPS with SSD

        SEO Hosting

        Dedicated C Class Hosting

      • Additional Services
        • Domains
        • Domain ID Protect
        • LogicScan
        • Spam Expert
        • SSL Certificates
      • Hosting Technology
        Learn about our security & performance optimizations.
        View Now
      • Data Center
        Take a tour of our modular data center. Our infrastructure is redundant & optimized for performance.
        Tour Now
    • IP Leasing
    • Servers
    • VPS
    • Hosting
      • Dedicated Servers
      • Domains
      • Reseller Hosting
      • SEO Hosting
      • SSL Certificates
      • VPS
      • Web Hosting
      • WordPress Hosting
    • IP Leasing
    • Support
      • Blog
      • Knowledgebase
      • My Account
    • Company
      • Acceptable Use Policy
      • Contact Us
      • Data Center
      • DMCA
      • FAQ
      • Guarantee Policy
      • Privacy Policy
      • Terms of Service
    • Customer Reviews

    Auto Delete Trash Folders on cPanel Servers Using Dovecot

    • admin
    • August 20, 2015
    • Leave a comment
    • cpanel, delete trash folders

    If you are running Dovecot on your cPanel servers, you’ll have noticed that mail trash isn’t auto-deleted which is bloody annoying for you and for your customers.

    I’ve found this script on the cPanel forum that will delete email trash that is over 30 days old.

     

    #!/bin/bash
    MAILDIRS=$(find /home/*/mail/*/* -maxdepth 0 -type d)
    INBOXFOLDERS=(.Trash .Junk .Spam .Low\ Priority .cPanel\ Reports)
    for basedir in $MAILDIRS; do
      for ((i = 0; i < ${#INBOXFOLDERS[*]}; i++)); do
        for dir in cur new; do
          [ -e "$basedir/${INBOXFOLDERS[$i]}/$dir" ] && (
            echo "Processing $basedir/${INBOXFOLDERS[$i]}/$dir..."
            find "$basedir/${INBOXFOLDERS[$i]}/$dir/" -type f -mtime +30 -delete
          )
        done
      done
    done
    /scripts/generate_maildirsize --verbose --allaccounts --force
    

    To run, SSH into your server and create a file such as delete_email_trash.sh and make sure you give it executable permissions (chmod +x) and then run ./delete_email_trash.sh

    I’d add it to a daily cron.

    I’ve also put the script online site so you can use wget on the server to save you doing anything, I’ve put it in the /root folder

    cd /root
    wget http://tomyates.co.uk/auto_delete_spam.sh
    chmod +x auto_delete_spam.sh
    #add to crontab 
    (crontab -l; echo "30 1 * * * /root/auto_delete_spam.sh > /dev/null 2>&1") | crontab
    #run for first time
    /root/auto_delete_spam.sh

    source: http://tomyates.co.uk/2012/08/01/auto-delete-trash-folders-on-cpanel-servers-using-dovecot/

    Share :  

    August 20, 2015   3621    Email  
    Total 2 Votes:
    0
    2

    Tell us how can we improve this post?

    + = Verify Human or Spambot ?

    Related Knowledge Base Posts -

    • EXIM Commands
    • Cannot Receive Email via POP3 in cPanel
    • SpamExpert Hosted Cloud Incoming Filtering

    Leave a Comment Cancel reply

    You must be logged in to post a comment.

    SSD VPS Hosting
    View VPS Plans
    Check out our high performance SSD powered VPS plans. More flexibility, affordability and options than anyone else.
    See Web Hosting Plans

    Our Advantage

    Robust Infrastructure

    Redundant Network & Servers. Enterprise Grade Equipment.

    Courteous Support

    Get timely, courteous tech support responses with a prompt resolution.

    Better Value

    We offer far more unique cPanel features and tools than any competitor.

    SSD WordPress Hosting

    WordPress Plans
    WordPress hosting with ultimate SSD performance, security and optmization in mind. Guaranteed!

    Need Support?

    Please open a support ticket via our 24/7 portal and a tech will respond to your inquiry promptly.

    Submit Ticket

    Services

    Bulk IPv4 Leasing
    Domains
    Web Hosting
    Reseller Hosting
    Dedicated Servers
    VPS | SEO VPS

    Company

    About Us
    Testimonials
    Guarantee Policy
    IP Leasing Policy
    Privacy
    AUP | DMCA | TOS

    Support

    Blog
    Contact Us
    Customer Portal
    FAQ
    Knowledgebase
    LogicWeb Reviews
    LOGICWEB Reviews
    See why LogicWeb is your #1 hosting choice.

    © 2021 All rights reserved | LogicWeb Inc.

    • Sign in
    • New Account
    Forgot Your Password ?