quota-status for outgoing mail (Dovecot/Postfix)

John Fawcett john at voipsupport.it
Sun Dec 6 22:56:56 EET 2020

On 06/12/2020 21:13, Peter Folta wrote:
> [Dovecot version (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


The dovecot quota-status service only checks the recipient address. In
order to achieve this with the quota-status service, you'd need to
change the source code introducing the capability to check the sender
address. You'd also need a way to differentiate when to use the existing
capability to check recipient and when to use the new capability to
check sender. One way of doing that would be to use the policy_context
attribute available in Postfix 3.1 and later in order to differentiate
whether you are calling quota-status for inbound or outbound email, example:




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://dovecot.org/pipermail/dovecot/attachments/20201206/a9a51927/attachment-0001.html>

More information about the dovecot mailing list