Change/fix Dovecot used quota handling
This is about an enhancement request and bug report, see discussion here: https://www.howtoforge.com/community/threads/dovecot-and-quota.74125/
Also related to: https://git.ispconfig.org/pkdevbox_y/ispconfig3/blob/master/server/lib/classes/cron.d/100-monitor_email_quota.inc.php
The gist of the enhancement request (quotes from the above post):
- dovecot checking is broken, it checks the wrong variable ($dovecot is never set to true)
- (Till) I guess we can remove the recalc anyway as it works without it and the command is not run at the moment or at least we just run it not that often like once a day or once every week. We might be able to alter the code to do a fallback to query the dovecot command for the quota in case that the dovecot command is there but the .quotausage file does not exist, so it should provide a fallback for custom setups like yours that use dovecot but don't have the .quotausage file.
- (me) If you run doveadm quota get -A, you get all mailbox quotas to iterate over in a simple loop, and with something like doveadm quota get -u '*@domain.com' it's possible to add some filtering. Well, that assumes you have an iterate_query definition, which IIRC the current ISPC config template doesn't have - though it's very easy to implement, just a single select query and config line, something like:
iterate_query = select email from mail_user where access = 'y'
Since I think Dovecot has probably the largest user base nowadays, it might be beneficial to fix that calculation method to use doveadm according to the above. It allows to use existing setups (such as mine, hence the enhancement request) without much change and choosing any quota backend, besides being more efficient than file-based ones.