HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Tips/Tricks/Mods (http://www.howtoforge.com/forums/forumdisplay.php?f=29)
-   -   How to build an email alert notification when a customer is using all his quota space (http://www.howtoforge.com/forums/showthread.php?t=38956)

voltron81 8th September 2009 18:15

How to build an email alert notification when a customer is using all his quota space
 
Hello to everybody,
I'm realizing a mail server with ISPConfig 3 and Roundcube.

I would like to realize an "email alert notification" to send to a customer that is using almost all his email space.

Do you have some idea how to realize it?

Thanks

Michele

voltron81 9th September 2009 18:29

I've found a script that check the quota of each email and, if it's more that 90%, it will send an email to me and the customer.

But I think that having this funcion integrated in ISPConfig could be just great...

Any idea?

Thanks
Michele

voltron81 15th September 2009 18:39

I was studing a bit the problem, and I realized that into the dbispconfig database there is a table names mail_user, where there is a quota field.

So I think that the logic way to solve the problem is realize a script that check that quota field for every email and, when this quota is 80% that the space assigned to the customers, just send an email to them saying that the space is almost finished.
Do you think it is difficult to realize?
Any idea?

Thanks
Michele

falko 16th September 2009 13:55

Should not be too difficult if you use a scripting language like PHP. :)

voltron81 16th September 2009 14:32

Yes, I'm trying to write a PHP script.
I'm with manuals and books studying what I've to do :o

Basically I've integrated a slider into Roundcube. This slider have 11 steps.
With ISPConfig I've created 11 spam policy, I now the policy_id of that policy.

So now what I want to do is connect PHP with MySQL, so that I could realize something like that:
Code:

$db_host = "localhost";
        $db_user = "root";
        $db_password = "password";
        $db_name = "dbispconfig";
        $db = mysql_connect($db_host, $db_user, $db_password);
       
        if ($db == FALSE)
        die ("Communication error. Please check the parameters of the connection to the mysql database");

        mysql_select_db($db_name, $db)
        or die ("Communication error. Please check the parameters of the connection to the mysql database");

        mysql_query("UPDATE spamfilter_users SET policy_id = '$VALUE_SPAM' WHERE email = '$ROUNDCUBE_USER'");
        //where $VALUE_SPAM is the value of the spam policy releated with the slider level

        mysql_close($db);


        $out .= "</table>";

        return $out;

At the moment I've 2 problems:
1) I don't know where to find the $ROUNDCUBE_USER, means the email of the user that at that time is using roundcube
2)I don't know where this slider is setting his variables releated with the status (0-10)

Suggestions?

mixo 19th November 2009 10:30

Hello,
I've ISPConfig 2 and want the same feature.Inform users with mail, when quota is more then 90%.

Has anybody made such a script?

damir 19th November 2009 10:47

This is something i would look to have integrated in ispconfig so im following your adventure voltron81 :)

voltron81 23rd November 2009 18:33

Great damir...
Let me know your news about that... :p

markbecken09 11th December 2009 14:06

Hey,
I've found a script that check the quota of each email and, if it's more that 90%, it will send an email to me and the customer.But I think that having this funcion integrated in ISPConfig could be just great...
Any idea?


Thanks.

mixo 11th December 2009 22:33

I have written such a script.
I will be glad if anyone uses it :)
Code:

#!/bin/bash

/usr/sbin/repquota -au |grep web| sed 's/ \+/ /g' | cut -f1,3,4 -d" " | while read LINE
do
USED=`echo $LINE | cut -f2 -d" "`
QUOTA=`echo $LINE | cut -f3 -d" "`
# TO AVOID DIVISION BY NULL LET'S INCREMENT QUOTA
let "QUOTA +=1"
#CALCULATE PERCENT
let RESULT=USED*100/QUOTA
if [ $RESULT -ge 90 ]&&[ $RESULT -lt 150 ]; then
    NAME=`echo $LINE | cut -f1 -d" "`
    # SEND MAIL
      SUBJ="-= Your mailbox is full =-"
      mutt  -s "$SUBJ" $NAME@example.ge < /usr/src/scripts/message.txt
fi
done



All times are GMT +2. The time now is 14:57.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.