cp /etc/exim.pl /etc/exim.pl.bak
nano /etc/exim.conf
sub check_limits
{
my $count = 0;
open (LIMIT, "/etc/virtual/limit");
my $email_limit = int(<LIMIT>);
close(LIMIT);
#find the curent user
$uid = find_uid();
#log_str("Found uid: $uid\n");
if (uid_exempt($uid)) { return "yes"; }
my $name="";
if ($email_limit > 0)
{
#check this users limit
if (($name = getpwuid($uid)))
{
$count = (stat("/etc/virtual/usage/$name"))[7];
if ($count > $email_limit)
{
die("You ($name) have reach your daily email limit of $email_limit emails\n");
}
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"
}
sub check_limits
{
my $count = 0;
#find the curent user
$uid = find_uid();
$name = getpwuid($uid)
open (LIMIT, "/etc/virtual/limit");
my $email_limit = int(<LIMIT>);
close(LIMIT);
#log_str("Found uid: $uid\n");
open (USERLIMIT, "/etc/virtual/$name.limit");
my $user_limit = int(<USERLIMIT>);
close(USERLIMIT);
if (uid_exempt($uid)) { return "yes"; }
my $name="";
if ($email_limit > 0 or $user_limit > 0)
{
#check this users limit
$count = (stat("/etc/virtual/usage/$name"))[7];
if ($count > $email_limit)
{
die("You ($name) have reach your daily email limit of $email_limit emails\n");
}
if ($count > $user_limit)
{
die("You ($name) have reach your daily email limit of $email_limit emails\n");
}
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"
}
echo 300 > /etc/virtual/username.limit
/sbin/service exim restart
rm -f /etc/exim.pl
mv /etc/exim.pl.bak /etc/exim.pl
/sbin/service exim restart
is it posible to set a maximum per user for sending email through smtp, f.i. 250 emails / day or so?
Hello, i active the limit send per day, but the problem is in one user (mine) show me more than 111111 and im limit to 1000, and other thing, im just setup a new account im only sent 1 email but showme 11, so its working this system?
I can see using this to avoid mail servers sending spam, but I'm not sure it will help you control your own users. Either they send email from your server (you can't block your own server from sending email) or they send it from their home or office connection on which the IP# will change.Code:warn ratelimit = 1000 / 12h / per_rcpt / strict delay = 30s log_message = Sender $sender_address rate $sender_rate / $sender_rate_period excedes limit delayed 30 seconds
Does your code also limit 127.0.0.1 (localhost)? If so, then won't it limit mailing lists run on the server?