Can I delete or move mail files from maildir cur folder?

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.

Asked By: henry

||

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.

Answered By: Celada

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
Answered By: sebix
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.