I am currently trying to figure out how I can delete old e-mails in one folder of a Maildir installation on a Debian server. Basically what I want to do is to run a cron job every day or so that checks a specific folder in the Maildir for old e-mails and deletes them if they are older than a set amount of days.
Is there a simple way to filter e-mails from a Maildir by date or do I have to read in every e-mail as text, look for the timestamp, convert it, subtract the mentioned amount of days and then compare it to the current date?
I don't want to invent the wheel if there are already better wheels out there, so I would be glad if someone could help me out in doing this.
Note: I am using Debian 7.8 with Postfix 2.9.6 & Dovecot 2.1.7