13

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"?

Andrew B
  • 31,858
  • 12
  • 90
  • 128
guettli
  • 3,113
  • 14
  • 59
  • 110

1 Answers1

12

Yes

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:

freiheit
  • 14,334
  • 1
  • 46
  • 69
  • 4
    And while dovecot does maintain its own internal indexes, it looks like it will end up rebuilding them for you: http://www.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