Tag Archives: Linux

A simple script to delete old spam on CPanel servers (or other Maildir based mailboxes)

I manage a CPanel server that gets hit with a ton of spam. Disk space is cheap, but there are better things to waste it on than old spam. Create a shell script with the commands below and set it to run automatically via cron, and you’ll clear out messages older than 30 days from your spam folders:

Note that the ‘Spam’ folder on my server is called ‘.spam’ but depending on your IMAP namespace and other variables, you may need to tweak that part of the script.

Share on Facebook