I use dovecot IMAP server and want to delete big unneeded mails:

cd /var/spool/foouser; du -a | sort -rn > /var/tmp/du-mail-foouser.log

Now I see big mails at the top and after looking at them I want to remove them.

Is it safe to just call

"rm ./foofolder/1318412893.M857530P4656.hz1,W=14463815,S=14268320:2,S"?



In this particular case, you are using a 'Maildir' format mailbox. In Maildir, it's safe to use 'rm' to remove an individual piece of email, to use 'mv' to move an individual mail between folders on the same file system, etc.

With other mail storage types, it may not be safe to rm a single email.

More about Maildir:

| improve this answer | |
  • 4
    And while dovecot does maintain its own internal indexes, it looks like it will end up rebuilding them for you: dovecot.org/list/dovecot/2009-July/040896.html – Andrew B Jan 10 '13 at 22:34
  • This is good to know. I have a "spam" mailbox which currently contains eleven-thousand emails, and none of my mail clients can handle even attempting to list the thing. Even Linux has issues doing an "ls" on it. – Piku Oct 16 '16 at 18:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.