• Introducing WebPros Cloud - a fully managed infrastructure platform purpose-built to simplify the deployment of WebPros products !  WebPros Cloud enables you to easily deliver WebPros solutions — without the complexity of managing the infrastructure.
    Join the pilot program today!
  • Support for BIND DNS has been removed from Plesk for Windows due to security and maintenance risks.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS.

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