• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Mailbox Quota Reaching Notifications

J

JARB

Guest
How do i create in Plesk 9.3 notyfication to admin and client if cleint mailbox is full


Please help

this shel script will be work on plesk 9.3 Debian ?

#! /bin/sh
# warn plesk mailbox users, if mailbox exceeds quota
#
#setenv QMAILUSER 'do-not-reply'
MAILROOT=/var/qmail/mailnames
ADMINMSG=''
cd $MAILROOT > /dev/null
for DIR in *.*;do
QUOTAFILE=$MAILROOT/$DIR/@mbox.quota
# if domainquota exists
if [ -f $QUOTAFILE ]
then
DOMAINHARDQUOTA=`cat $QUOTAFILE`
DOMAINSOFTQUOTA=$((85 * $DOMAINHARDQUOTA / 100))
#echo "$DIR $DOMAINHARDQUOTA - $DOMAINSOFTQUOTA"
cd $MAILROOT/$DIR
for MAILBOX in * ;do
if [ -d $MAILBOX ]
then
# look for specific mailbox quota file and set mailbox softquota
QUOTAFILE=$MAILROOT/$DIR/$MAILBOX/@mbox.quota
#echo $QUOTAFILE
if [ -f $QUOTAFILE ]
then
HARDQUOTA=`cat $QUOTAFILE`
#echo "using specific $QUOTAFILE, $HARDQUOTA"

SOFTQUOTA=$((85 * $HARDQUOTA / 100))
else
#echo "using domainquota"
HARDQUOTA=$DOMAINHARDQUOTA
SOFTQUOTA=$DOMAINSOFTQUOTA
fi
# calculate space used by mailbox
MBOXSPACE=`du -ks $MAILBOX | cut -f1`
#echo "$MAILBOX@$DIR uses $MBOXSPACE"
if [ $HARDQUOTA -gt 0 -a $MBOXSPACE -gt $SOFTQUOTA ]; then
MBOXPERCENT=$(($MBOXSPACE * 100 / $HARDQUOTA))
echo "$MAILBOX@$DIR belegt $MBOXSPACE kb, Soft/Hardquota = $SOFTQUOTA kb /$HARDQUOTA kb"

#for testing: send warn mail to postmaster account
#mail -r do-not-reply@$DIR -s "Mailbox Quota Warnung" [email protected] << EOF
#
#regular: send warn mail to mailbox
mail -r do-not-reply@$DIR -s "Mailbox Quota Warnung" $MAILBOX@$DIR << EOF


Dear $MAILBOX

Your Mailbox currently uses $MBOXSPACE kb ($MBOXPERCENT %) on the mailserver. We would like to
remind you that your mailbox may only contain $HARDQUOTA kb.

To avoid problems when receiving new mail, you should remove read mail from the server.


Regards,
mailbox-robot
EOF



fi
fi
done;

fi



done;
cd /root/bin
 
Last edited by a moderator:
after run this script a have error :


/var/www/vhosts/mydomain/private/mailboxfull.sh: line 7: cd: /var/qmail/mailnames
: No such file or directory
/var/www/vhosts/mydomain/private/mailboxfull.sh: line 8: syntax error near unexpected token `do
'
/var/www/vhosts/mydomain/private/mailboxfull.sh: line 8: `for DIR in *.*;do


Can you help ?
 
Last edited by a moderator:
cd: /var/qmail/mailnames: No such file or directory

Do you have /var/qmail/mailnames directory on your server?
psa-mail-driver-common package contains this directory. Do you have installed this package? Do you have qmail or postfix as your MTA?
 
yes

it's my ls ls -a /var/qmail/ result

.
..
mailnames
popuser
 
what im doing wrong

a run script in cron as root

bash /var/www/vhosts/mydomain/private/mailboxfull.sh
 
Back
Top