Just to level-set, I am using Centos7-arm which supplies Dovecot 2.2.10. I don't have access to a arm build or mock environment and use what is available (I DID try to install them but had dependency issues). Much of what I have is from campworld, but some I have picked up from other Centos mailserver builders. Also I am using Postfixadmin which provides quotas per user in mysql database. To access those quotas for dovecot, I have the following script: cat <<EOF>/etc/dovecot/dovecot-dict-quota.conf || exit 1 connect = host=localhost dbname=postfix user=postfix password=$Postfix_Database_Password map { pattern = priv/quota/storage table = quota2 username_field = username value_field = bytes } map { pattern = priv/quota/messages table = quota2 username_field = username value_field = messages } EOF Where $Postfix_Database_Password is an env variable in my install howto. I am setting up quota plugins as follows: sed -i "/#mail_plugins/ a mail_plugins = quota sieve" /etc/dovecot/conf.d/15-lda.conf sed -i "/#mail_plugins / a mail_plugins = quota imap_quota trash" /etc/dovecot/conf.d/20-imap.conf sed -i "/#mail_plugins/ a mail_plugins = quota" /etc/dovecot/conf.d/20-pop3.conf But I am having 'challenges' with how to actually enable quotas and understanding 90-quota.conf. I am starting from campworld's 'reduced' dovecot.conf seeing: dict { quotadict = mysql:/etc/dovecot/dovecot-dict-quota.conf } and plugin { quota = dict:user::proxy::quotadict acl = vfile:/etc/dovecot/acls trash = /etc/dovecot/trash.conf sieve_global_path = /home/sieve/globalfilter.sieve sieve = ~/dovecot.sieve sieve_dir = ~/sieve sieve_global_dir = /home/sieve/ #sieve_extensions = +notify +imapflags sieve_max_script_size = 1M } I have put the sieve plugin lines into the 90-sieve.conf and the acl into 10-acl.conf. Trash is a separate matter for a later question... So I am looking for guidance as to how to integrate the Postfixadmin quota information properly into 90-quota.conf thank you
I spent an evening, again, reading up on quota. This time I think my search foo was strong enough. I found guidance and came up with the following: sed -i -e "s/#quota = /sqlquota = /w /dev/stdout" /etc/dovecot/dovecot.conf Sets up a dovecot dictionary of sqlquota to the default file of /etc/dovecot/dovecot-dict-sql.conf.ext cat <<EOF>>/etc/dovecot/conf.d/90-quota.conf || exit 1 plugin { quota = dict:user::proxy::sqlquota } EOF Appends to the end of 90-quota.conf (tried to do with with a single SED, but it was getting messy) finally: cat <<EOF>/etc/dovecot/dovecot-dict-sql.conf.ext || exit 1 connect = host=localhost dbname=postfix user=postfix password=$Postfix_Database_Password map { pattern = priv/quota/storage table = quota2 username_field = username value_field = bytes } map { pattern = priv/quota/messages table = quota2 username_field = username value_field = messages } EOF Please let me know if I missed something here. Thanks On 03/17/2017 09:08 AM, Robert Moskowitz wrote:> Just to level-set, I am using Centos7-arm which supplies Dovecot > 2.2.10. I don't have access to a arm build or mock environment and > use what is available (I DID try to install them but had dependency > issues). > > Much of what I have is from campworld, but some I have picked up from > other Centos mailserver builders. > > Also I am using Postfixadmin which provides quotas per user in mysql > database. To access those quotas for dovecot, I have the following > script: > > cat <<EOF>/etc/dovecot/dovecot-dict-quota.conf || exit 1 > connect = host=localhost dbname=postfix user=postfix > password=$Postfix_Database_Password > map { > pattern = priv/quota/storage > table = quota2 > username_field = username > value_field = bytes > } > map { > pattern = priv/quota/messages > table = quota2 > username_field = username > value_field = messages > } > EOF > > Where $Postfix_Database_Password is an env variable in my install howto. > > I am setting up quota plugins as follows: > > sed -i "/#mail_plugins/ a mail_plugins = quota sieve" > /etc/dovecot/conf.d/15-lda.conf > sed -i "/#mail_plugins / a mail_plugins = quota imap_quota trash" > /etc/dovecot/conf.d/20-imap.conf > sed -i "/#mail_plugins/ a mail_plugins = quota" > /etc/dovecot/conf.d/20-pop3.conf > > But I am having 'challenges' with how to actually enable quotas and > understanding 90-quota.conf. I am starting from campworld's 'reduced' > dovecot.conf seeing: > > dict { > quotadict = mysql:/etc/dovecot/dovecot-dict-quota.conf > } > > and > > plugin { > quota = dict:user::proxy::quotadict > acl = vfile:/etc/dovecot/acls > trash = /etc/dovecot/trash.conf > sieve_global_path = /home/sieve/globalfilter.sieve > sieve = ~/dovecot.sieve > sieve_dir = ~/sieve > sieve_global_dir = /home/sieve/ > #sieve_extensions = +notify +imapflags > sieve_max_script_size = 1M > } > > > > I have put the sieve plugin lines into the 90-sieve.conf and the acl > into 10-acl.conf. Trash is a separate matter for a later question... > > So I am looking for guidance as to how to integrate the Postfixadmin > quota information properly into 90-quota.conf > > thank you >
Robert, If you wish, you can go one step further and configure postfix to reject mail -5.X.X DSN- when user is over quota instead of having the mail waiting in the postfix mail queue for considering it a temporary delivery problem -4.X.X DSN-. When the problem is considered temporary postfix will retry to send the e-mail several times (sometimes for a whole week) and the sender wouldn't even know that their message didn't get to the recipient. With a permanent error, the sender is immediately informed that their mail couldn't make it to the recipient's inbox. In order to do this, you need to tell postfix and dovecot to talk together using the LMTP protocol. To achieve this, two things : 1/ In dovecot : configure the lmtp service and tell it that postfix will talk to it through the /var/spool/postfix/private/dovecot-lmtp unix socket. In conf.d/10-master.conf : service lmtp { unix_listener /var/spool/postfix/private/dovecot-lmtp { group = postfix mode = 0600 user = postfix } } Here, dovecot will create the socket in postfix's chroot directory just to make sure it can access it (in case it runs chrooted, which is the default in debian). Should you have created the socket outside of postfix's chroot, then postfix wouldn't have access to it. In order for dovecot to create that socket it needs to connect as the postfix system user and group. In Debian, postfix chroot is /var/spool/postfix/. 2/ In postfix : use the lmtp service as your transport and set the "next hop" (postfix's jargon) to the unix dovecot-lmtp socket (that dovecot will create for you). This is done by editing postfix's main.cf : virtual_transport = lmtp:unix:private/dovecot-lmtp you should also find an lmtp line in master.cf, it should read like this : lmtp unix - - - - - lmtp you can leave that unchanged. If you do 1/ and 2/, dovecot will inform postfix (via the LMTP protocol) that the user is over quota and mail should be rejected (not held in queue), postfix will then bounce to the sender, informing them that their message couldn't be delivered : This is the mail system at host my.mailserver.tld I'm sorry to have to inform you that your message could not be delivered to one or more recipients. It's attached below. [...] <s.merrouche at my.mailserver.tld>: host my.mailserver.tld[private/dovecot-lmtp] said: 552 5.2.2 <s.merrouche at my.mailserver.tl> Quota exceeded (mailbox for user is full) (in reply to end of DATA command) -- Yassine