admin warning when mailbox full

petersconsult

Verified User
Joined
Sep 10, 2021
Messages
71
Hello All,

Is there any way for the admin (owner/User) of a given domain/Account to receive an email when any of the mailboxes in that account is full (or, ideally, when it reaches 98% or some such)?

i found an old thread but it references pages that have now disappeared into the ether..

i would greatly appreciate any help on this matter,
Thank you all!!
Be Well!
 
Hello,

Try this on your own risk:

With a DirectAdmin CustomBuild 2.0 Dovecot 2.x setup, you can quickly enable and 80%, 95% and 100% notices by typing:

Bash:
cd /etc/dovecot/conf.d
wget -O 91-quota-warning.conf http://files.directadmin.com/services/all/91-quota-warning.conf
wget -O /usr/local/bin/quota-warning.sh http://files.directadmin.com/services/all/quota-warning.sh
chmod 755 /usr/local/bin/quota-warning.sh

and restart Dovecot:

Bash:
systemctl restart dovecot.service

The commands should be run as root in a SSH console.
 
One could use even this script:

- /usr/local/bin/quota-warning.sh

Bash:
#!/bin/bash
##
## Patched by Poralix (www.poralix.com)
## -- Wed Apr 24 08:17:52 CEST 2024
##

PERCENT=$1;
USER=$2;
DOMAIN=$3;
FROM="${USER}";
ADMIN=$(grep "^email=" /usr/local/directadmin/data/users/admin/user.conf | cut -d= -f2);

if [ "$#" -eq 0 ]; then
        echo "Usage: $0 <percent> <email> <domain>";
        exit 1;
fi

do_send_warning()
{
cat << EOF | /usr/libexec/dovecot/dovecot-lda -d ${1} -o "plugin/quota=maildir:User quota:noenforcing"
Date: $(date --rfc-email)
To: ${1}
From: ${FROM}
Reply-To: ${ADMIN}
Subject: Email Quota Usage: ${PERCENT}%

Hello,

This is an automated notification letting you know that an email account:

- ${USER}

has used ${PERCENT}% of it's available space.

You might either clear used disk space or get increase it's size.

Regards,
$(hostname -f)
EOF

}

test -n "${USER}" && do_send_warning "${USER}";
test -n "${ADMIN}" && do_send_warning "${ADMIN}";

To warn an user and admin about the quota usage. Here is in the script admin's email is get from admin's settings in DirectAdmin. It is stored in the file /usr/local/directadmin/data/users/admin/user.conf.

And yes, the script requires an administrator account "admin" to exist. If you don't have the "admin" account on a server you might change "admin" in the line:

Code:
/usr/local/directadmin/data/users/admin/user.conf

to something else, example:

Code:
/usr/local/directadmin/data/users/SecretAdmin/user.conf

a fake name SecretAdmin is used, you will replace it with your own.
 
Hi @zEitEr ,
Wow! Thank You so much for all this info!!
i haven't had the time to take care of this, which is why i haven't responded, but i wanted to thank you because getting this up and running would help me a lot..
i am more interested in getting alerts to the admin account (me), but alerts to users are definitely useful too..
i will definitely get back to you with info on whether it worked..
Thank You So Much for this help!!!

It works perfectly!
Thank You Very Much!!
 
Last edited:
Actually, there is one small issue: that script sends an email every 5 minutes or so..
i changed the breakpoints to 99%, 97%, and 95%, that way it'll only send messages when it's an absolute emergency..

Thank You!
 
Back
Top