Mail Limiter per User

Change code in “/etc/exim.pl” under “check_limits”

sub check_limits

{

my $count = 0;

#find the current user

$uid = find_uid();

if (uid_exempt($uid)) { return "yes"; }

my $name = "";

my $email_limit = 0;

if (($name = getpwuid($uid))) {

if (-e "/etc/virtual/limit.$name") {

open (LIMIT, "/etc/virtual/limit.$name");

$email_limit = int(<LIMIT>);

close(LIMIT);

} else {

open (LIMIT, "/etc/virtual/limit");

$email_limit = int(<LIMIT>);

close(LIMIT);

}

if ($email_limit > 0) {

$count = (stat("/etc/virtual/usage/$name"))[7];

if ($count > $email_limit) {

die("You ($name) have reach your daily email limit of $email_limit emailsn");

}

open (USAGE, ">>/etc/virtual/usage/$name");

print USAGE "1";

close (USAGE);

chmod (0660, "/etc/virtual/usage/$name");

}

}

my $sender_address = Exim::expand_string('$sender_address');

my $mid = Exim::expand_string('$message_id');

log_bandwidth($uid,"type=email&email=$sender_address&method=outgoing&id=$mid");

return "yes"

}

PS. You will need to create a file “/etc/virtual/limit.USERNAME”. Otherwises, it will call global value from “/etc/virtual/limit”