MTPolicy Configuration for LDAP mail sending quota

When dealing with different groups of users, such as Students and Teachers, IT might need to restring the number of E-Mails a user can send. MTpolicy can limit the number of E-Mails a user can send based on Extended Attributes in the UMC, allowing for an easy administration of the limits.

You can find MTPolicy in the unmaintained repository and a sample implementation of the configuration in the cool-solutions repository. You can activate both via UCR

ucr set repository/online/component/cool-solutions=yes \
repository/online/component/cool-solutions/version="current" \
repository/online/component/cool-solutions/unmaintained=yes \
repository/online/unmaintained=yes

Afterward, you can install MTPolicy via univention-install

univention-install univention-mtpolicy

Next, you will need to create an extended attribute to manage the Mail Quota in the UMC. The following command creates the extended attribute, utilizing the LDAP attribute univentionFreeAttribute15.

udm settings/extended_attribute create --position "cn=custom attributes,cn=univention,dc=mtpolicy,dc=univention,dc=de" \
--set CLIName=MailSendingLimit \
--set groupName="Send Quota" \
--set ldapMapping=univentionFreeAttribute15 \
--set longDescription="Limit on send E-Mails" \
--set mayChange=1 \
--set module="users/user" \
--set multivalue=0 \
--set name=MailSendingLimit \
--set notEditable=0 \
--set objectClass="univentionFreeAttributes" \
--set shortDescription="Mail Sending Limit" \
--set syntax=integerOrEmpty \
--set tabAdvanced=1 \
--set tabName=Mail \
--set valueRequired=0 \
--set version=2

To connect the extended attribute to MTPolicy, replace the template file in

/etc/univention/templates/files/etc/mtpolicyd/mtpolicyd.conf

with the one attached to this thread. Afterward, Commit the file, connect MTPolicy to postfix and restart both MTPolicy and postfix:

ucr commit /etc/mtpolicyd/mtpolicyd.conf
ucr set mail/postfix/smtpd/restrictions/recipient/79='check_policy_service inet:127.0.0.1:12345'
systemctl restart mtpolicyd
systemctl restart postfix

For any user, who does not have a limit configured, you set a default via UCR with:

ucr set mtpolicyd/threshold=1254

mtpolicyd.conf.txt (2.5 KB)

1 Like
Mastodon