If you are not restricted to using dovecot and postfix only, I suggest having a look at policyd "cluebringer" - from https://wiki.policyd.org/
Works great to set quotas per user or per domain. On 06.12.20 21:13, Peter Folta wrote: > [Dovecot version 2.3.11.3 (502c39af9)] > > Hi all, > > I’m using Dovecot’s quota-status service to let Postfix check the > recipient’s quota before accepting emails following the guide > here: https://blog.sys4.de/postfix-dovecot-mailbox-quota-en.html > <https://blog.sys4.de/postfix-dovecot-mailbox-quota-en.html>. This > works well for inbound emails. > > I would like to set up something similar for outbound email, i.e. if a > user is over quota, they should not be allowed to send new emails. At > the moment, the setup is in a bit of an inconsistent state: Users that > have exceeded their quota are still able to send outbound emails but > saving them in their Sent folder will fail leaving them without a copy. > > I have tried using Dovecot’s quota-status in Postfix’s > smtpd_send_restrictions but didn’t get this to work. A quick look at > the Dovecot source code seems to suggest that the quota-status plugin > is only checking the recipient > address: > https://github.com/dovecot/core/blob/master/src/plugins/quota/quota-status.c#L135-L146 > <https://github.com/dovecot/core/blob/master/src/plugins/quota/quota-status.c#L135-L146> > and > https://github.com/dovecot/core/blob/master/src/plugins/quota/quota-status.c#L109-L111 > <https://github.com/dovecot/core/blob/master/src/plugins/quota/quota-status.c#L109-L111>. > > I suspect it’s not possible to use the quota-status service to control > outbound email but thought I’d ask to confirm. I’m wondering if > there’s a different way to achieve this? > > Thanks > Peter