Dovecot + quotes (с отправкой уведомлений)

 

Включение оповещений при превышении квоты

ee /usr/local/etc/dovecot/conf.d/90-quota.conf
plugin {
 quota = maildir:User quota
 quota_rule = *:storage=500M
 quota_rule2 = Trash:storage=+100M
 quota_rule3 = Junk:ignore
 quota_grace = 10%%

 # Quota plugin can also limit the maximum accepted mail size.
 #quota_max_mail_size = 100M
}

# Описываем SQL словарь
dict {
 sqlquota = mysql:/usr/local/etc/dovecot/dovecot-dict-sql.conf.ext
}

plugin {
 quota_warning = storage=95%% quota-warning 95 %u
 quota_warning2 = storage=80%% quota-warning 80 %u
 quota_warning3 = storage=70%% quota-warning 70 %u
 quota_warning4 = storage=60%% quota-warning 60 %u
 quota_warning5 = storage=50%% quota-warning 50 %u
}
service quota-warning {
 executable = script /usr/local/bin/quota-warning.sh
 unix_listener quota-warning {
    user = nobody
    group = nobody
    mode = 0666
    }
 #user = dovecot
}

############# Проверяю ###########
service quota-warning {
  executable = script /etc/dovecot/quota-warning.sh
  unix_listener quota-warning {
        user = vmail
        group = mail
        mode = 0660
        }
}

service quota-exceeded {
  executable = script /etc/dovecot/quota-exceeded.sh
  unix_listener quota-exceeded {
        user = vmail
        group = mail
        mode = 0660
        }
}

plugin {
    quota = dict:User quota::proxy::quota
    quota_warning = storage=100%% quota-exceeded 100 %u
    quota_warning2 = storage=90%% quota-warning 90 %u
    quota_warning3 = storage=80%% quota-warning 50 %u
 }
 
service quota-warning {
  executable = script /etc/dovecot/quota-warning.sh
  unix_listener quota-warning {
       user = vmail
       group = mail
       mode = 0660
       }
}
 
service quota-exceeded {
   executable = script /etc/dovecot/quota-exceeded.sh
   unix_listener quota-exceeded {
       user = vmail
       group = mail
       mode = 0660
       }
}

####################

Скрипт:

cat /usr/local/bin/quota-warning.sh
#!/bin/sh
PERCENT=$1
USER=$2
cat << EOF | /usr/local/libexec/dovecot/dovecot-lda -d $USER -o "plugin/quota=maildir:User quota:noenforcing"
From: postmaster@uni.ka
Subject: quota warning
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
To: $USER

Внимание!
Ваш ящик заполнен на $PERCENT%.

Attention!
Your mailbox is now $PERCENT% full.
EOF

Просмотр квоты пользователя (также можно просмотреть в WEB-интерфейсе PostfixAdmin)

doveadm quota get -u acc@uni.ka

Пересчитать квоту для конкретного пользователя

doveadm quota recalc -u acc@uni.ka

Проверка

/usr/local/bin/quota-warning.sh 85% acc@uni.ka

 

 

Источник

Leave a Reply

Your email address will not be published. Required fields are marked *