Re: [Exim] Limit outbound emails per hour on user basis

Top Page
Delete this message
Reply to this message
Author: Christian Vogel
Date:  
To: Avleen Vig
CC: Yogesh Sharma, exim-users
Subject: Re: [Exim] Limit outbound emails per hour on user basis
Hi Avleen,

On Sat, Dec 13, 2003 at 03:34:53AM -0800, Avleen Vig wrote:
> >         INSERT INTO mails (user,when) VALUES ('${X}',now())
> > the other one returns the number of entries in the database in a specific timeframe.
> >         SELECT COUNT(user) FROM mails WHERE user='${X}' AND when > (now()-3600)
> You'll also need a either somethign in exim, or something outside exim,
> to delete entires > 3600 old, or you'll have one huge db.


Yes, of course, that would be necessary regularly, but then you could
also use something like this (also not tested at all):

        UPDATE mail SET value=value*EXP(-(NOW()-timestap)*decay)+1,
               timestamp=NOW()
               WHERE user='${X}'


        (timestamp is unix-seconds (unsigned int), value and decay are something
         floating point, user is the thing you use for accounting)


and then check if afterwards, value is over some threshold. This will give your
customer some amount of mails he can send at once (the
threshold) and a "decay constant" which tells him how fast this number of mails
accumulated will decay over time to allow for new mails to be sent
again.

A decay constant of 0.000277 (1/3600) means that he can send roughly two thirds
(1 - 1/e) of his threshold's mails per hour continuously.

        Chris


--
Christian Vogel -- chris@???