View Full Version : email limit send mail
sander815
05-31-2004, 04:35 AM
is it posible to set a maximum per user for sending email through smtp, f.i. 250 emails / day or so?
DirectAdmin Support
05-31-2004, 03:07 PM
We'll be looking at something like that when we update exim and include the new exim.conf (jlaman's).. and integrated spamassasin controls. No eta though.
John
kotakomputer
10-16-2009, 08:25 PM
How about the progress after 6 years?
nobaloney
10-17-2009, 08:48 AM
It was added on September 7, 2005. There's the relevant post in the DirectAdmin Knowledgebase (http://help.directadmin.com/item.php?id=81).
Jeff
viciovirtual
11-03-2009, 04:53 PM
Hi im check the DirectAdmin Knowledgebase and works, but i want know if i can setup custom number of emails to some accounts, like:
admin - 2000 dayli mails
xxxx- 200 dayli mails
xxxx - 500 dayli mails
nobaloney
11-04-2009, 10:29 AM
I don't think it can be done that way. Perhaps someone else will respond.
Jeff
getUP
11-04-2009, 10:43 AM
It is possible, but will require some adjustments. Please note that the following code is untested and usage is at your own risk
Create a copy of your exim.pl and open it:
cp /etc/exim.pl /etc/exim.pl.bak
nano /etc/exim.conf
Replace
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"
}
With:
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"
}
Create a limitation:
echo 300 > /etc/virtual/username.limit
And restart Exim:
/sbin/service exim restart
You can revert your changing as well:
rm -f /etc/exim.pl
mv /etc/exim.pl.bak /etc/exim.pl
/sbin/service exim restart
nobaloney
11-04-2009, 10:55 AM
Note that exim.pl is occasionally updated by DirectAdmin staff; when they do that you'll have to update your customized file yourself.
Jeff
getUP
11-04-2009, 12:38 PM
Good point.
I thought you could already set limits on a per user basis, but it seemed I was wrong. So perhaps there is someone else who can confirm this already is a feature.
viciovirtual
11-04-2009, 03:56 PM
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?
is it posible to set a maximum per user for sending email through smtp, f.i. 250 emails / day or so?
I do something like this in exim.conf:
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
This will throttle any IP that trys to send to over 1000 recipients in a 12 hour period. Not sure if that is something like you want or not. More info at exim.org on ratelimit. We also enforce another ratelimit is Squirrelmail.
Matthew
floyd
11-11-2009, 08:29 AM
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?
Just remember in the usage files 111111 is 6 emails. 11 is 2 emails.
nobaloney
11-11-2009, 06:45 PM
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
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.
Jeff
A home PC infected with a virus will pump out tens of thousands of emails. This does a very good job of stopping/slowing it and is exactly what I use it for. Keeps my server from getting blacklisted. IP's on broadband accounts do not change that rapidly usually.
http://www.exim.org/exim-html-current/doc/html/spec_html/ch40.html#useratlim
Matt
nobaloney
11-12-2009, 09:03 AM
Interesting point... should I perhaps consider adding this code to the SpamBlocker exim.conf file? Community input welcomed.
Jeff
interfasys
11-14-2009, 06:15 AM
I think it would be a sensible option to have in exim for hosting providers
nobaloney
11-14-2009, 08:10 AM
@hci:
Does your code also limit 127.0.0.1 (localhost)? If so, then won't it limit mailing lists run on the server?
Jeff
Does your code also limit 127.0.0.1 (localhost)? If so, then won't it limit mailing lists run on the server?
I don't beleive so but it does limit squirrelmail. It can be setup to ignore 127.0.0.1 to avoid this. I have had spammers break into squirrelmail accounts though so I also added the limit senders plugin to squirrelmail and removed all other webmail clients.
Mattew
nobaloney
11-15-2009, 09:10 AM
I'd like to see some additional input. Someone please update this thread by Monday morning if no-one else has, so I'll see it and act on it.
Thanks.
Jeff
Powered by vBulletin™ Version 4.0.4 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.