Thursday, October 20, 2011

OS X Lion & Mail Quotas

Since OS X Lion no longer offer a GUI to change the Mail Quota size of a user, I had to find out a new way.
I know that for individual users it is possible to do this using the Directory Utility.

But that's not what I want if I have to change dozens of users.

So I figured out a way to do this using dscl:

This is how you read the current value of the Mail Quota:

MailQuota=`dscl /LDAPv3/my.server.com -readpl /Users/$theUser MailAttribute kUserDiskQuota`

And this way you may set a new value:

dscl -u diradmin -P $diradminpass /LDAPv3/my.server.com -createpl /Users/$theUser MailAttribute kUserDiskQuota $newvalueInMB

Unfortunately this value does not get updated on the mail server immediately.
In order to get the mail server to update the quotas, you have to do this:
Delete or rename /var/db/.mailusersettings.plist

Then manually recreate the file '/var/db/.mailusersettings.plist':

serveradmin stop mail
rm  /var/db/.mailusersettings.plist
touch /var/db/.mailusersettings.plist
chown _postfix:mail /var/db/.mailusersettings.plist

chmod g+w /var/db/.mailusersettings.plist 
serveradmin start mail

Restarting the mail service updates the per user mail quota defined in OD.

What might also help is to try this:

doveadm quota recalc -u username

No comments: