Using Dovecot, I ran into quite a disturbing problem when it comes to inboxes purge. Here's my setup :
- Dovecot stores its users/mailboxes on a MySQL backend.
- Postfix handles email transmissions, and relies on Dovecot for authentication.
- Inboxes are stored in
Quite the basic setup. Now imagine the following scenario :
- I create a user in my database (let's say email@example.com), and start sending and receiving emails. No problems, everything goes fine.
- I don't need my user anymore, I just delete it from the database, no more user.
But here's the problem... At this moment,
/var/mail/mydomain.tld/johndoe) still exists. Now imagine :
- Another John Doe appears, and he wants an inbox. I add firstname.lastname@example.org to the database, great, it works!
Now here's the funny thing : previous John Doe didn't delete his emails before leaving, and new John Doe has gained access to the previous mailbox contents (as addresses are the same, he was given the same inbox location). Let's hope John Doe number 1 hasn't let credentials, credit card information or something similar in his inbox...
So here's my question : is there a proper way to delete actual inboxes when deleting a Dovecot user ? In my example, I'd like
/var/mail/mydomain.tld/johndoe to be deleted when first John Doe disappears (step 2, on service restart maybe?). Now, I could do this programmatically using my frontend application (a PHP application which fills the MySQL backend), but that would create a mess with permissions (allow the web user to access mailboxes, no thanks!)