Blog

Blog

18
Feb
2010

Deleting QMAIL Email by Date

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

/etc/init.d/qmail stop

Command to remove all the old messages:

find /var/qmail/mailnames/<domain>/<user>/Maildir/curr -mtime +X -print | xargs rm

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 $.

/etc/init.d/qmail start

Tags: , ,
Category: General
  • WOW!!! this has been a great help in removing very old emails from certain email accounts easily!

    many many thanks

    Comment by paris — March 8, 2011 @ 7:01 pm

  • Absolutely indited written content , regards for information .

    Comment by Hisako Yakulis — November 7, 2011 @ 7:16 pm

Leave a comment

Spam Protection by WP-SpamFree