HowTo implement "soft" quota for Dovecot

The configuration of the mailstack that is implemented in UCS allows to configure a quota
The documentation of this feature states:
“The size of the users’ mailboxes can be restricted via the mail quota. When this is attained, no further emails can be accepted for the mailbox by the mail server until the user deletes old mails from their account.”

While this approach is often used especially for public mail service, companies and institutions may want to implement a quota without the fear to “lose” informations. It should be noted that the messages are not lost, but the sender needs to recognise the bounce-message and decide to use other methodes to submit the information. It is hard to understand that the sender needs to that just because the recipient did not clean up the mailbox.

The following approach tries to implement the mailquota in a way that messages will arrive even if the quota is reached and only the owner of the mailbox will get notified at least when he tries to send a new message.

The friest step is to disable the quota check in Postfix.
The default is defined as

mail/postfix/smtpd/restrictions/recipient/80: check_policy_service inet:127.0.0.1:12340
 Variables in the format mail/postfix/smtpd/restrictions/recipient/SEQUENCE=RULE can be used to configure recipient restrictions using the Postfix option 'smtpd_recipient_restrictions' (see <http://www.postfix.org/postconf.5.html#smtpd_recipient_restrictions>). The sequence numbers are sorted alphabetically and ensure the order.

After unsetting this UCRV and restarting the MTA Postfix will not reject anymore.

ucr unset mail/postfix/smtpd/restrictions/recipient/80 && systemctl postfix restart

But now Dovecot still checks the quota and would still reject. This is done by the LMTP component which is using a set of plugins that are defined by several configuration files in the /etc/dovecot/conf.d/directory. It depends on the specfic environment which services are active. This is an example of the active configuration on a system that has also “OX AppSuite” installed:

root@dn001:~# doveconf 2>/dev/null | grep -A2 "^protocol lmtp"
protocol lmtp {
  mail_plugins = " acl quota quota sieve notify push_notification"
}

We can see that there are for some reasons even 2 mentions of the quota plugin. Most likely it is defined more than once…
But we can always override those settings by using the /etc/dovecot/local.conf which is automatically included at the end of the dovecot configuration. We just need to take the configuration shown above but without the quota plugin.

root@dn001:/etc/dovecot# cat local.conf 
protocol lmtp {
  mail_plugins = "acl sieve notify push_notification"
}

root@dn001:/etc/dovecot# doveconf 2>/dev/null | grep -A2 "^protocol lmtp"
protocol lmtp {
  mail_plugins = "acl sieve notify push_notification"
}

After a restart Dovecot will accept arriving messages even if over quota but will continue to check it for protocols like imap. It depends on the usage scenario which errors the mailbox-owners may see. User of the “OX AppSuite” for example will see an error message during compose that the draft can not be saved due to the limit defined by the quota. Extended testing is therefore highliy recommended.

This topic was automatically closed after 24 hours. New replies are no longer allowed.

Mastodon