How to auto-delete spambox emails older than x days?

electric

Well-Known Member
Nov 5, 2001
742
5
318
Hello,

Many of our customers have enabled the "Spam Box" feature in the SpamAssassin.

As a result.. we are finding about 150gb of disk space is used by the many .spam folders that are created. Most customers never click the "Clear Spam Box" button, so their spam emails are sitting there for years, and it adds up when there are a lot of customers and spam.

Is there a setting in cpanel somewhere so admin can automatically delete all emails in all Spam Box folders on the server that are older than x days? (For example 60 or 90 days..)

Thanks!
 
Last edited:

cPanelMichael

Technical Support Community Manager
Staff member
Apr 11, 2011
47,911
2,234
363
cPanel Access Level
DataCenter Provider
Twitter
Is there a setting in cpanel somewhere so admin can automatically delete all emails in all Spam Box folders on the server that are older than x days? (For example 60 or 90 days..)
Hello,

We introduced the Email Disk Usage option in cPanel 64:

In cPanel & WHM version 64, we have made cleaning your mailboxes easier with cPanel's Email Disk Usage interface (Home >> Email >> Email Disk Usage). The tool allows you to view all of your mailboxes and quickly remove old emails or large messages. We have also integrated this into the mailbox quota notifications to provide users quick access.
There's no corresponding option to use this for all accounts from WHM, but the following WHM API 1 functions are available to make the task a little easier:

WHM API 1 Functions - expunge_mailbox_messages - Software Development Kit - cPanel Documentation
WHM API 1 Functions - expunge_messages_for_mailbox_guid - Software Development Kit - cPanel Documentation

Thank you.
 

electric

Well-Known Member
Nov 5, 2001
742
5
318
Thanks. Unfortunately, the new "Email Disk Usage" is not very helpful for us because, like most hosting providers, we allocate lots of disk space to the customer, so there is no *need* for the customer to use this feature until it is necessary for them.

In other words, this new feature is really only helpful for customers who are receiving disk usage notifications. Until that happens, most customers won't know or care about their email account disk space usage. And that is usually not very often, since it is very unusual to *not* oversell disk space.

For example, let's say we give a 5gb disk space limit to all our customer. (Not oversold too much.) But we have 200 customers, and each of them has 1gb of spambox junk mail. Now that's a LOT of disk space that is used, but the customers don't even know about it so they will never use the "Email Disk Usage" feature.. and our server's disk space is being used for nothing.

What is needed is a WHM "Tweak Server" setting where admin can specify the desired maximum time limit for any messages in the Spam Box. For example:

-----------
Delete all emails in Spam Box after [ x ] days. (Default to 90 days.)
-----------

Then if you wanted to get fancy, you could add a configurable option in the customer's cpanel spam assassin page under the "Spam Box" section. (So they can overwrite the server default, if desired.) (And add another option in WHM tweak settings, which says, "Allow cpanel account users to overwrite this setting above. [ ] Yes [x] No"

I'm willing to pay for this, since it would result in a lot of reclaimed disk space.

Thanks.

PS - It needs to work for both maildir and mbox formats, of course. ;)