If postfix
do not attempt to perform LDA itself and invoke dovecot's deliver
instead, then postfix
do not need to know about quotas at all.
If you have used postfixadmin
for virtual domains management, then you already have everything you need for quota restrictions. You have to modify dovecot
's SQL query to fetch user's quotas:
user_query = SELECT maildir AS home, \
26 AS uid, \
26 AS gid, \
CONCAT("*:bytes=",quota) AS quota_rule \
FROM mailbox \
WHERE username = '%n@%d' \
AND active=1;
(do not blindly copy-paste that example, use it as template)
Then you have to setup quota plugin and warning service in the dovecot.conf
UPDATED:
. . . . . .
# this line enable quota plugin!
mail_plugins = quota
# here is the plugin's configuration
plugin {
quota = maildir:User quota
quota_rule = Junk:ignore
quota_rule2 = Trash:storage=+100M
quota_warning = storage=90%% quota-warning 90 %u %d
quota_warning2 = storage=80%% quota-warning 80 %u %d
quota_exceeded_message = ERROR:422 - Mailbox full, sorry.
. . . . .
}
. . . . .
service quota-warning {
executable = script /path/to/the/overquota.sh
user = $mail_uid
group = $mail_gid
unix_listener quota-warning {
user = $mail_uid
group = $mail_gid
}
}
. . . . .
overquota.sh
should look like that:
#!/bin/sh
cat << EOT | /usr/local/libexec/dovecot/dovecot-lda -d $2 -o "plugin/quota=maildir:User quota:noenforcing"
From: postmaster@$3
To: $2
Subject: == Quota warning ==
Content-Type: text/plain; charset="UTF-8"
Your mailbox is $1% full, so clean up your mess, please!
EOT
exit 0
####
When dovecot's deliver
try to store the message into inbox, it check whether the quota was reached predefined thresholds 80% and 90% or no. If so - quota-warning service is invoked and script is launched, that place a warning message into mailbox - without further quota checkout.
Put four blank spaces at the beginning of each line to format as a code block. You can select in the edit window and use the
{}
button for this. – a CVn – 2015-06-03T11:38:19.107i used pastebin link, ithink that would be readable – satch_boogie – 2015-06-03T11:40:57.707
#main.cf http://pastebin.com/H9HEmzkP
– satch_boogie – 2015-06-03T11:52:40.390