[horde] Limit recipients in Horde?

Andy Dorman adorman at ironicdesign.com
Thu Nov 19 23:10:30 UTC 2009


Michel Bulgado wrote:
> Hi
> 
> Anybody know if horde is possible to limit the number of recipients to
> send in Horde.
> 
>  both for the line of the from, cc or bcc?
> 
> Thanks
> 

Michael, this is actually harder to do than it seems at first.

I am working on a submit to the wiki about it that will include our code.  But 
this is a summary of what was involved when we did it...

1.  Set the limits. We set up a system that stored per-email and per-24hr limits 
for each user in our LDAP database.  Then we use preference hook code to pull in 
the values for a user when they log in.

However, if you have a small group of users and can set the same limits for 
everyone, you could set these up as a fixed (non-editable by the user) 
preference in horde/config/prefs.php

2. Then when a user sends email, you will need code in 
horde/imp/lib/Compose->sendMessage that does the following just before actually 
sending the email:

   - adds up the number of recipients for that email
   - checks to see if the number exceeds the "per email" limits.
   - grab how many this sender has already sent over the last 24hr (we use 
memcache for this), add the number for this email and see if they have exceeded 
the max for the last 24 hr.
   - if the email is about to be sent, don't forget to add the number of 
recipients back to the 24hr number and save it for the next email they send.

3. When the limit is exceeded, you can do
return PEAR::raiseError($message) and the message will not be sent.  Also, the 
$message text can tell the user whatever you want.

4. I would also recommend you add a _perms_hook_denied hook when someone exceeds 
the limits to notify you AND possibly deactivate a sender when they exceed the 
limits so you can investigate.

Hope this helps.  I will try to get the exact code into the wiki within the next 
few days.

-- 
Andy Dorman
Ironic Design, Inc.
AnteSpam.com, HomeFreeMail.com, ComeHome.net


More information about the horde mailing list