Hi Christian,

Thanks for replying!

It seems that your comments (or perhaps some of my recent config tinkering) helped, because once I tried just now to make it go from 89% to 91%, and I did receive the quota warning!

Thanks!

MJ

Op 15-12-2021 om 15:23 schreef Christian Mack:
Hello

Just to clarify.
You only will getting an over quota once, you step over one or multiple
of those quota warning limits while storing an email.

Therefore you will not get any warning, just because you are over that
85% limit.
If you receive another email in that account, and go at least over 90%,
then dovecot will call your script once.
If you also go over 100% with that same mail, you will not get one for
90% or 95%, but only one for 100%.

You also should check, if you have any environment variables set, which
are not present, when your script is run by dovecot.
Do you have any logging in it?


Kind regards,
Christian Mack

Am 15.12.21 um 14:06 schrieb mj:
Hi,

I am still struggling with this, and would appreciate any help ayone can
give. Let me try to explain step for step.

I created a test account t...@company.com:

root@dovecot:/# doveadm quota get -u test
Quota name Type    Value
Limit
%
            STORAGE  1209
1368
88
            MESSAGE    35
-
0

As you can see, the test mailbox is 88% full, so it should receive
warnings, because in dovecot.conf I have set:

plugin {
   quota = maildir
   quota_rule = ?:storage=5G
   quota_rule2 = Trash:storage=+100M
   quota_warning = storage=97%% quota-warning 97 %u
   quota_warning2 = storage=95%% quota-warning 95 %u
   quota_warning3 = storage=90%% quota-warning 90 %u
   quota_warning4 = storage=85%% quota-warning 85 %u
   quota_warning5 = storage=80%% quota-warning 80 %u
   quota_warning6 = -storage=100%% quota-warning below %u
}

We use a script to send out the email warnings, configured like this:

service quota-warning {
   executable = script /usr/local/bin/quota-warning.sh
   unix_listener quota-warning {
     user = vmail
     mode = 0666
   }
   user = vmail
}

When running this script manually as vmail, the warning is delivered to
the test user:

sudo -H -u vmail bash -c '/usr/local/bin/quota-warning.sh 90 test'

However, in practice: dovecot never sends out any quota-warnings. It
just starts generating delivery failures when the mailbox is over 100%.

We define the per-user quota in the first line of each user's
maildirsize file, for the test user: /var/vmail/test/Maildir/maildirsize

Here is a debug=yes log file of 88% full incoming mailbox delivery:

Dec 15 13:56:07 mail dovecot: lda(t...@company.com)<20290><>: Debug:
Loading modules from directory: /usr/lib/dovecot/modules
Dec 15 13:56:07 mail dovecot: lda(t...@company.com)<20290><>: Debug:
Module loaded: /usr/lib/dovecot/modules/lib01_acl_plugin.so
Dec 15 13:56:07 mail dovecot: lda(t...@company.com)<20290><>: Debug:
Module loaded: /usr/lib/dovecot/modules/lib02_lazy_expunge_plugin.so
Dec 15 13:56:07 mail dovecot: lda(t...@company.com)<20290><>: Debug:
Module loaded: /usr/lib/dovecot/modules/lib10_quota_plugin.so
Dec 15 13:56:07 mail dovecot: lda(t...@company.com)<20290><>: Debug:
Module loaded: /usr/lib/dovecot/modules/lib15_notify_plugin.so
Dec 15 13:56:07 mail dovecot: lda(t...@company.com)<20290><>: Debug:
Module loaded: /usr/lib/dovecot/modules/lib20_mail_log_plugin.so
Dec 15 13:56:07 mail dovecot: lda(t...@company.com)<20290><>: Debug:
Module loaded: /usr/lib/dovecot/modules/lib20_zlib_plugin.so
Dec 15 13:56:07 mail dovecot: lda(t...@company.com)<20290><>: Debug:
Module loaded: /usr/lib/dovecot/modules/lib90_sieve_plugin.so
Dec 15 13:56:07 mail dovecot: lda(t...@company.com)<20290><>: Debug:
auth USER input: test uid=5000 gid=5000 home=/var/vmail/test
Dec 15 13:56:07 mail dovecot: auth: Debug: master in:
USER#0111#011t...@company.com#011service=lda
Dec 15 13:56:07 mail dovecot: auth: Debug: userdb out:
USER#0111#011test#011uid=5000#011gid=5000#011home=/var/vmail/test
Dec 15 13:56:07 mail dovecot: lda(t...@company.com)<20290><>: Debug:
changed username to test
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: Effective uid=5000,
gid=5000, home=/var/vmail/test
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: lazy_expunge: No
lazy_expunge setting - plugin disabled
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: Quota root: name=
backend=maildir args=
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: Quota rule: root=
mailbox=? bytes=5368709120 messages=0
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: Quota rule: root=
mailbox=Trash bytes=+104857600 messages=0
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: Quota warning:
bytes=5207647846 (97%) messages=0 reverse=no command=quota-warning 97
test
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: Quota warning:
bytes=5100273664 (95%) messages=0 reverse=no command=quota-warning 95
test
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: Quota warning:
bytes=4831838208 (90%) messages=0 reverse=no command=quota-warning 90
test
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: Quota warning:
bytes=4563402752 (85%) messages=0 reverse=no command=quota-warning 85
test
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: Quota warning:
bytes=4294967296 (80%) messages=0 reverse=no command=quota-warning 80
test
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: Quota warning:
bytes=5368709120 (100%) messages=0 reverse=yes command=quota-warning
below test
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: Quota grace: root=
bytes=536870912 (10%)
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: Namespace :
type=shared, prefix=shared/%n/, sep=/, inbox=no, hidden=no,
list=children, subscriptions=no
location=maildir:/var/vmail/%u/Maildir:LAYOUT=fs:DIRNAME=mAildir:INDEX=/var/vmail/test/shared/%u

Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: shared:
root=/var/run/dovecot, index=, indexpvt=, control=, inbox=, alt=
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: acl: initializing
backend with data: vfile
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: acl: acl username = test
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: acl: owner = 0
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: acl vfile: Global
ACLs disabled
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: Namespace inbox:
type=private, prefix=, sep=/, inbox=yes, hidden=no, list=yes,
subscriptions=yes
location=maildir:/var/vmail/test/Maildir:LAYOUT=fs:DIRNAME=mAildir
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: fs:
root=/var/vmail/test/Maildir, index=, indexpvt=, control=, inbox=, alt=
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: acl: initializing
backend with data: vfile
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: acl: acl username = test
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: acl: owner = 1
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: acl vfile: Global
ACLs disabled
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: quota:
quota_over_flag check: quota_over_script unset - skipping
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: Quota root: name=
backend=maildir args=
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: Quota rule: root=
mailbox=? bytes=5368709120 messages=0
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: Quota rule: root=
mailbox=Trash bytes=+104857600 messages=0
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: Quota warning:
bytes=5207647846 (97%) messages=0 reverse=no command=quota-warning 97
raw mail user
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: Quota warning:
bytes=5100273664 (95%) messages=0 reverse=no command=quota-warning 95
raw mail user
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: Quota warning:
bytes=4831838208 (90%) messages=0 reverse=no command=quota-warning 90
raw mail user
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: Quota warning:
bytes=4563402752 (85%) messages=0 reverse=no command=quota-warning 85
raw mail user
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: Quota warning:
bytes=4294967296 (80%) messages=0 reverse=no command=quota-warning 80
raw mail user
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: Quota warning:
bytes=5368709120 (100%) messages=0 reverse=yes command=quota-warning
below raw mail user
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: Quota grace: root=
bytes=536870912 (10%)
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: quota:
quota_over_flag check: quota_over_script unset - skipping
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: Destination address:
<t...@company.com> (source: -a parameter)
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: sieve: Pigeonhole
version 0.5.4 () initializing
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: sieve: include:
sieve_global is not set; it is currently not possible to include
`:global' scripts.
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: sieve: file storage:
Using active Sieve script path: /var/vmail/test/.dovecot.sieve
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: sieve: file storage:
Using script storage path: /var/vmail/test/sieve
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: sieve: file storage:
Relative path to sieve storage in active link: sieve/
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: sieve: file storage:
Using Sieve script path: /var/vmail/test/.dovecot.sieve
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: sieve: file storage:
Storage path `/var/vmail/test/.dovecot.sieve' not found
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: sieve: file storage:
Using Sieve script path: /var/lib/dovecot/default.sieve
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: sieve: file script:
Opened script `default' from `/var/lib/dovecot/default.sieve'
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: sieve: Using the
following location for user's Sieve script:
/var/lib/dovecot/default.sieve
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: sieve: Opening script
1 of 1 from `/var/lib/dovecot/default.sieve'
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: sieve: Loading script
/var/lib/dovecot/default.sieve
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: sieve: Script binary
/var/lib/dovecot/default.svbin successfully loaded
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: sieve: binary save:
not saving binary /var/lib/dovecot/default.svbin, because it is
already stored
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: sieve: Executing
script from `/var/lib/dovecot/default.svbin'
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: Mailbox INBOX:
Mailbox opened because: lib-lda delivery
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: Quota root :
Recalculated relative rules with bytes=1400000 count=0. Now grace=140000
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: Debug: Mailbox INBOX: saving
UID 0: Opened mail because: mail stream
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: save: box=INBOX, uid=20,
msgid=<46e7b334-80a0-3a99-4494-bc6fd07aa...@external.com>, from=user
name <u...@external.com>, subject=test
Dec 15 13:56:07 mail dovecot:
lda(test)<20290><cqPGJOfluWFCTwAA4uZ9mg>: sieve: u...@external.com |
test | msgid=<46e7b334-80a0-3a99-4494-bc6fd07aa...@external.com>:
stored mail into mailbox 'INBOX'
Dec 15 13:56:07 mail postfix/pipe[20088]: 76722819170D6:
to=<t...@company.com>, relay=dovecot, delay=0.24,
delays=0.2/0.02/0/0.03, dsn=2.0.0, status=sent (delivered via dovecot
service)
Dec 15 13:56:07 mail postfix/qmgr[19577]: 76722819170D6: removed

I would appreciate any help. :-)

Finally, our dovecont -n running-config:

root@dovecot:# dovecot -n
# 2.3.4.1 (f79e8e7e4): /etc/dovecot/dovecot.conf
# Pigeonhole version 0.5.4 ()
# OS: Linux 4.19.0-17-amd64 x86_64 Debian 10.11 xfs
# Hostname: mail.company.com
auth_debug = yes
auth_failure_delay = 10 secs
auth_master_user_separator = *
auth_mechanisms = plain login
auth_username_format = %Ln
auth_verbose = yes
auth_verbose_passwords = sha1
default_vsz_limit = 512 M
deliver_log_format = %f | %s | msgid=%m: %$
lda_mailbox_autocreate = yes
lda_mailbox_autosubscribe = yes
login_greeting = Dovecot ready.
login_log_format_elements = user=<%u> method=%m rip=%r lip=%l mpid=%e
%c lport=%a
mail_gid = vmail
mail_location = maildir:/var/vmail/%Ln/Maildir:LAYOUT=fs:DIRNAME=mAildir
mail_plugins = acl lazy_expunge zlib quota mail_log notify
mail_shared_explicit_inbox = yes
mail_uid = vmail
managesieve_notify_capability = mailto
managesieve_sieve_capability = fileinto reject envelope
encoded-character vacation subaddress comparator-i;ascii-numeric
relational regex imap4flags copy include variables body enotify
environment mailbox date ihave
namespace {
   list = children
   location =
maildir:/var/vmail/%%u/Maildir:LAYOUT=fs:DIRNAME=mAildir:INDEX=/var/vmail/%u/shared/%%u

   prefix = shared/%%n/
   separator = /
   subscriptions = no
   type = shared
}
namespace inbox {
   inbox = yes
   location =   mailbox "Deleted items" {
     special_use = \Trash
   }
   mailbox Drafts {
     special_use = \Drafts
   }
   mailbox Junk {
     special_use = \Junk
   }
   mailbox Sent {
     special_use = \Sent
   }
   mailbox "Sent items" {
     special_use = \Sent
   }
   mailbox Trash {
     special_use = \Trash
   }
   mailbox inbox {
     auto = subscribe
   }
   prefix =   separator = /
   type = private
}
passdb {
   args = /etc/dovecot/deny.imap
   deny = yes
   driver = passwd-file
}
passdb {
   args = /etc/dovecot/master-users
   driver = passwd-file
   master = yes
}
passdb {
   args = /etc/dovecot/dovecot-ldap.conf.ext
   driver = ldap
   result_failure = return-fail
}
plugin {
   acl = vfile
   acl_shared_dict = file:/var/lib/dovecot/db/shared-mailboxes.db
   mail_log_events = delete undelete expunge copy mailbox_delete
mailbox_rename append
   mail_log_fields = uid box msgid from subject
   quota = maildir
   quota_rule = ?:storage=5G
   quota_rule2 = Trash:storage=+100M
   quota_warning = storage=97%% quota-warning 97 %u
   quota_warning2 = storage=95%% quota-warning 95 %u
   quota_warning3 = storage=90%% quota-warning 90 %u
   quota_warning4 = storage=85%% quota-warning 85 %u
   quota_warning5 = storage=80%% quota-warning 80 %u
   quota_warning6 = -storage=100%% quota-warning below %u
   sieve = ~/.dovecot.sieve
   sieve_default = /var/lib/dovecot/default.sieve
   sieve_dir = ~/sieve
}
protocols = imap lmtp sieve
service auth {
   unix_listener /var/spool/postfix/private/auth {
     mode = 0666
   }
   unix_listener auth-userdb {
     group = vmail
     mode = 0666
     user = vmail
   }
}
service imap-login {
   process_limit = 500
   process_min_avail = 2
}
service quota-warning {
   executable = script /usr/local/bin/quota-warning.sh
   unix_listener quota-warning {
     mode = 0666
     user = vmail
   }
   user = vmail
}
service stats {
   unix_listener stats-reader {
     group = vmail
     mode = 0666
     user = vmail
   }
   unix_listener stats-writer {
     group = vmail
     mode = 0666
     user = vmail
   }
}
shutdown_clients = no
ssl = required
ssl_cert = </etc/ssl/letsencrypt/fullchain.pem
ssl_cipher_list =
ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384

ssl_dh = # hidden, use -P to show it
ssl_key = # hidden, use -P to show it
ssl_min_protocol = TLSv1.2
userdb {
   args = uid=vmail gid=vmail home=/var/vmail/%n allow_all_users=yes
   driver = static
}
userdb {
   args = /etc/dovecot/dovecot-ldap.conf.ext
   driver = ldap
}
verbose_proctitle = yes
protocol lda {
   mail_plugins = acl lazy_expunge zlib quota mail_log notify sieve quota
}
protocol imap {
   imap_max_line_length = 2 M
   mail_max_userip_connections = 40
   mail_plugins = acl lazy_expunge zlib quota mail_log notify
imap_quota imap_acl
}

Thanks very much for your help!

MJ


Reply via email to