[Dovecot] deleting maildir files

Don Russell russell.don at gmail.com
Mon Jul 16 20:23:13 EEST 2007


Tom Bombadil wrote:
> Greetings all...
>
> Can we delete maildir files directly from the file system?
>
> Basically, we use dovecot to train spam, and we want to delete messages
> that are older than 30 days, using a simple "find /maildirs -cname +30
> -name *imap-server* -exec rm {} \;"
>
> I have seen a post a while ago saying that dovecot can rebuild the
> indexes, but I don't remember if it's when the index is deleted or when
> the maildir files are deleted.
>
> And if we cannot delete files with the 'rm' command, whats the
> best/proper way to delete these older files.
>
> Thanks
>   

My opinion has always been that the data structure should not be replied 
upon.... if you want to do things with your mail items, then use the 
APIs/imap commands to do it. That protects you from any internal stuff 
you didn't know about, or changed from one server to another, or one 
version to another.

For example, I have the beginnings of a script to handle my "mail 
retention policies". It connects to Dovecot/imap to get the list of mail 
for specific folders, then uses the imap delete (or copy) API to delete 
mail older than n days, or to keep only the most recent n messages. That 
sort of thing.

The benefit is my script then doesn't care how Dovecot (or whichever 
server) stores things.... and if a mailbox changes from mbox to maildir 
format, or similar change.. no worries... my script just doesn't care... 
it always uses the APIs to manipulate mail.

Safe, but admittedly not as fast. I favor reliability over speed in 
these sorts of cases.  :-)


More information about the dovecot mailing list