One of our customers had checked the “leave message on server” box, by accident in Outlook and over 8 months accumulated over 20,000 messages (mostly spam) on the server. The mailbox was close to 1.5GB in size.
Its a Qmail mail server.
First, find out exactly how many messages are in the box and sort by the largest message
ls -Slh | – less
The | less will allow you to go page by page. To exit type :q
He requested that we delete all the emails that were over 30 days old.
Then stop the server
Command to remove all the old messages:
replace +X with the number of days (so in our case it was +30)
the Maildir/new folder contains messages in the queue.
Depending on how many messages are in the folder the above command can take a few minutes – do not cancel until you get back to the prompt $.