Page 3 of 5

Re: Limit emails per hour per domain

Posted: Sun Sep 11, 2016 5:16 am
by mike08
You are a crack, it indeed work, it wasn't working for me the php scripts earlier as I was testing it with roundcube using the ww-data user, however it indeed blocks or limits connections for the entire account, useful when users are using old wordpress instances, outdated plugins or nulled content.

Good job.

Re: Limit emails per hour per domain

Posted: Sun Sep 11, 2016 11:25 am
by dpeca
One is glad to be of service ;)
This will also helps me, because I have a lot of servers :)

Re: Limit emails per hour per domain

Posted: Mon Dec 12, 2016 11:32 am
by mehargags
dpeca,
Can you please check if I got it correctly ?

What is this line ?? where to put it ?

Code: Select all

acl_not_smtp = acl_not_smtp
nano /etc/exim4/exim4.conf.template
# inside the section that says

Code: Select all

begin acl
# Towards the end of the section add the following text

Code: Select all

# for PHP scripts, limit per Vesta user
acl_not_smtp:
deny message = Web site of $authenticated_id user is sending too much emails - rate overlimit = $sender_rate / $sender_rate_period
ratelimit = 20 / 1h / $authenticated_id
accept
Did I get it all correct ?

Re: Limit emails per hour per domain

Posted: Thu Dec 15, 2016 10:40 am
by dpeca
mehargags wrote:dpeca,
Can you please check if I got it correctly ?

What is this line ?? where to put it ?
Image

Re: Limit emails per hour per domain

Posted: Thu Dec 15, 2016 2:57 pm
by mehargags
thx dpeca
Yes I got it later...!! thanks

Re: Limit emails per hour per domain

Posted: Sun Jan 22, 2017 9:22 pm
by kronz
To Summarize it all, here is what you have to do to get it all working. I had to read both threads until I get it right.

File to edit: /etc/exim4/exim4.conf.template
Find:

Code: Select all

begin acl
Before, add:

Code: Select all

acl_not_smtp = acl_not_smtp
Find:

Code: Select all

begin acl
After, add:

Code: Select all

# for PHP scripts, limit per vesta user
acl_not_smtp:
deny message = Web site of $authenticated_id user is sending too much emails - rate overlimit = $sender_rate / $sender_rate_period
ratelimit = 20 / 1h / $authenticated_id
accept
Find:

Code: Select all

acl_check_rcpt:
accept hosts = :
After, add:

Code: Select all

# for SMTP authenticated users, limit per email account
deny message = Email account $authenticated_id is sending too much emails - rate overlimit = $sender_rate / $sender_rate_period
ratelimit = 20 / 1h / $authenticated_id

File to edit: /etc/roundcube/defaults.inc.php
Change the settings in red to match those posted here.
$config['smtp_server'] = 'localhost';

// SMTP port (default is 25; use 587 for STARTTLS or 465 for the
// deprecated SSL over SMTP (aka SMTPS))
$config['smtp_port'] = 25;

// SMTP username (if required) if you use %u as the username Roundcube
// will use the current username for login
$config['smtp_user'] = '%u';

// SMTP password (if required) if you use %p as the password Roundcube
// will use the current user's password for login
$config['smtp_pass'] = '%p';

Re: Limit emails per hour per domain

Posted: Thu Jan 26, 2017 3:23 pm
by dpeca
Excelent kronz, thank you for summarizing :)

Re: Limit emails per hour per domain

Posted: Tue Feb 14, 2017 6:20 pm
by mehargags
A small clarification I need... Say I want to create MULTIPLE ACLs for acl_not_smtp:


I would only once define:

Code: Select all

acl_not_smtp = acl_not_smtp 
correct ??

Then
how do I define Multiple Acls per hour, per minute, per second like this ??

Code: Select all

acl_not_smtp_s:
  deny message = Web site of $authenticated_id user is sending too much emails - rate overlimit = $sender_rate / $sender_rate_period
  ratelimit = 20 / 1s / $authenticated_id
  accept

Code: Select all

acl_not_smtp:
  deny message = Web site of $authenticated_id user is sending too much emails - rate overlimit = $sender_rate / $sender_rate_period
  ratelimit = 200 / 1h / $authenticated_id
  accept
Am I doing it correctly ??
Sorry the Exim documentation is too damn reference only, no real examples to show real syntax. Please help me for this.

Re: Limit emails per hour per domain

Posted: Fri Feb 17, 2017 10:41 am
by dpeca
Only one

Code: Select all

acl_not_smtp = acl_not_smtp
and then:

Code: Select all

acl_not_smtp:
  deny message = Web site of $authenticated_id user is sending too much emails - rate overlimit = $sender_rate / $sender_rate_period
  ratelimit = 20 / 1s / $authenticated_id

  deny message = Web site of $authenticated_id user is sending too much emails - rate overlimit = $sender_rate / $sender_rate_period
  ratelimit = 200 / 1h / $authenticated_id

  accept

Re: Limit emails per hour per domain

Posted: Sun Feb 19, 2017 7:14 pm
by mehargags
Hey Dpecca,
Thanks a ton ... got the same reference from a friend... Will test it out soon and post results