How to empty an users inbox

Sometimes you may have a mailbox on a linux server with several thousand items in it that you wish to clear quickly. You can do this by following the following steps.

  1. Login to putty (https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html).
  2. Change directory to the folder you wish to empty in the following format: /home/[cpanel username]/mail/[domain.com - the part after the @ in the email]/[user - the part before the @ in the email]/[folder]/
    If you wish to clear the inbox, this is listed as "cur". Unread mail can be found in "new".
    e.g. for bob@example.com:
    cd /home/example/mail/example.com/bob/cur/
  3. find . -type f -delete

If you want to change to a directory and then see what folders are available, "cd" changes directory, "ls" lists the contents, for example:

cd /home/example/mail/example.com/
ls

This would list the available users @example.com.

cd /home/example/mail/example.com/bob/
ls

 This would list Bob's available folders.

WARNING: linux command line has the ability to delete/break everything very quickly, especially if you login as root.

Have more questions? Submit a request

Comments