10

I ended up with a cur folder with over 350,000 files. So many that I can't find a mail program to manage them. Tried horde on the same server and it gives an error.

Can I delete or move some of those files manually (shell)? Or would that create other problems (indexing)?

My first goal would be to end up with archive folders per year. Otherwise I'd have to just delete older files until the size becomes manageable again.

13

Yes, you may delete files from that folder manually. Dovecot is designed to assume that other software besides itself might manipulate the Maildir folder, including adding, removing, and renaming (the portion of the filename after the colon). It will update the indices accordingly as soon as it notices.

In order to avoid deleting those mails outright, you could also use regular shell utilities (mv, mkdir, etc...) to:

  • separate them into multiple smaller folders
  • move them out to a temporary location and move them in again in smaller bunches of manageable size
  • use a good IMAP client that synchronizes the folder contents without having to download everything. (unfortunately, good email clients are in short supply. They all suck. Some just suck less.

In contrast, you shouldn't try this if you are using Dovecot with dbox (either sdbox or mdbox). In that case, use doveadm commands to manipulate the mailbox contents without using an email client.

4
  • Much thanks. Regarding moving manually into folders. Can those folders be inside the maildir structure? Or should they be created somewhere else?
    – henry
    Jul 19 '15 at 20:43
  • 1
    Yes, you can effectively create new IMAP folders with regular mkdir because Maildir folders are just regular POSIX directories which happen to contain three subdirectories called cur, new, and tmp. Pay attention to the naming structure that your installation of Dovecot is using in order to know how you have to name such directories in order to get them recognized by Dovecot. Basically, I recommend using LAYOUT=fs in your Dovecot configuration, it's more intuitive because the IMAP folders are directly named after the directories.
    – Celada
    Jul 19 '15 at 20:48
  • that's so true that they all suck. The tools to manipulate emails on imap servers are very few, actually i know only the one embedded in mutt and it does not work easily on most servers. Others like offlineimap and mbsync do only syncing and even that is not done correctly. For example no one uses the Message-ID in the email header to check if it should be downloaded. Jun 14 '18 at 11:48
  • I was having trouble deleting mail folders in Thunderbird, so, based on your advise, I deleted them from the MailDir folder. After restring Thunderbird, I was then able to delete the ghosts of the folders. Thanks.
    – Manngo
    Oct 17 at 7:42
5

You can use dovecot's own tools for that, e.g. doveadm move. You can use search queries to select mails.

This selects all mails in a date range and moves them to the Archive

doveadm move -u jane Archive/2011/09 mailbox INBOX BEFORE 2011-10-01 SINCE 01-Sep-2011

To just search without action use the search command:

doveadm search -u jane mailbox INBOX BEFORE 2011-10-01 SINCE 01-Sep-2011

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.