Mrio Gamito wrote:
How can i set the size of the outgoing mails on a per user bases ?
I wrote a patch many years ago to do this. Grab
http://web.nilpotent.org/tmp/datalimits.tar.bz2
I can't be pisitive that it isn't buggy. I wrote it for a previous
workplace, and it worked for their use-cases; it might not for yours.
I can't remember my design decisions any more. If it does have bugs,
please let me know.
Here's the README from the file; it should help you decide if it'll
work for you:
I wrote this code mainly to limit outgoing mail messages. Mail sent from
one user to another user on the same mailhost is not checked for databytes
at all. You may want to change the islocal() function to suit your
environment.
The way it works is pretty simple. Place something like this in your
tcpserver control file:
# 192.168.1.x is your lan
192.168.1.:allow,RELAYCLIENT="",DATALIMIT=""
When qmail-smtpd starts up to deal with a connection, it does:
1. check if the DATALIMIT environment variable is set. if not, no limits
are applied.
2. read in a cdb with the addresses and their respective datalimits. if
the cdb can't be found, no limits are applied.
3. read in the sender info (other end sends
"mail from: <foo@example.com>").
4. read in the recipient info (other end sends
"rcpt to: <bar@bar.org>").
5. if the recipient's address is to the mail server, no limits are applied
(see above about the islocal() function).
6. if the sender is root, postmaster, abuse, hostmaster from any domain,
it's not checked for the datalimit. same for <> (bounces) and any
address without an @.
7. if the sender address isn't in the cdb, the DEFAULT entry applies. if
the DEFAULT entry doesn't exist, no limits are applied.
I keep the address info in /var/qmail/control/datalimit, and I have a
script called set-datalimit that creates /var/qmail/control/datalimit.cdb
(which is then read by qmail-smtpd). The format of the datalimit file is
simple:
-- cut here ---
# format is address=bytes
# if bytes is set to 0, the user has no limit.
# after making changes to this file, run /var/qmail/bin/set-datalimit
# the DEFAULT line affects all addresses not listed in this file.
# if it is removed, the rest of the file is not read, and no limits are
# set.
DEFAULT = 200000
# these people aren't limited at all:
big.boss@corp.dom = 0
her.secretary@corp.dom = 0
# set a higher limit for the sales people
johnd@corp.dom = 8000000
toshok-sunday-sunday-sunday@hungry.com = 8000000
-- cut here ---
set-datalimit is written in python using the python cdb module. All it
does is
1. create a cdb.
2. add address,datalimit pairs.
3. exit.
You can write your own script to do this using cdbmake or perl or
whatever.
Faried.
--
The Great GNU has arrived, infidels, behold his wrath !
(> (length "eclipse") (length "emacs"))
=> T
"vi doesn't care about black people!"
|