4

How can I implement "rate limit" in Exim so that every user in my exim can send specific number of emails per day.

List A of Users can send 100 emails per day and the list B of users can send 500 emails per day.

2 Answers 2

7

Expanding on HBruijn's answer, I recommend this ACL segment:

# Keep authenticated users under control
deny authenticated = *
     set acl_c_msg_limit=${lookup{$sender_address}nwildlsearch{/etc/exim/send_limits}}
     ratelimit = $acl_c_msg_limit / 1d / strict / $authenticated_id

Then you create the /etc/exim/send_limits file and have this in there:

# Commented lines and blank lines are ignored
# Format is     EMAIL: LIMIT
user1@domain1.com: 100
user2@domain1.com: 200
user3@domainXX.com: 100

# Must be the last line, this is the default limit
*@*: 50

This is untested, but it should get you headed in the right direction.

2
  • 1
    Where in the ACL section should you put this?
    – jdmayfield
    Feb 23, 2021 at 9:09
  • I don't know why but the last line of send_limits file '*@*' doesn't match as default.
    – Tobia
    Apr 29, 2021 at 9:31
2

The manual has a configuration example for a user based rate limiting setting:

# Keep authenticated users under control
deny authenticated = *
     ratelimit = 100 / 1d / strict / $authenticated_id

That restricts authenticated senders to 100 messages per day but which would also be global for all authenticated users.

3
  • You can enhance the answer by on the line before the ratelimit, adding a set acl_c_msg_limit=${lookup{$sender_address}nwildlsearch{/etc/exim/send_limits}}, then use that variable in the place of the "100" in your ratelimit. In the /etc/exim/send_limits, have AT THE END of the file "@: 10" (assuming that 10 is a good default). Any other email address, including using wildcards, can be to set the limit to 100 or 200 as he desires.
    – Todd Lyons
    Oct 14, 2014 at 12:22
  • That makes a much better answer than just leaving it as a comment.
    – HBruijn
    Oct 14, 2014 at 12:59
  • 3
    Maybe it's a stupid question, but, where should I insert this settings? Which is the right ACL? I'm using ubuntu server and it has exim configuration separated in many files, I'm a bit confused how to use this fragmented configuration.
    – Tobia
    May 10, 2019 at 8:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.