Limitation of sent messages in exim

exim

I want limit the messages which sent through exim per user or per domain. (for now interesting only message sent through php mail).

mails send from apache user (mod_php) so as I understand limit through user is not available, because i have only one user.

I think the better way limit by host. But the other problem it's subdomains.

Advise me how i can fix this.

Also I read about values $authenticated_id,$sender_host_authenticated,$sender_address etc. how I can trace this values?

For now i set limit for any users or hosts:

       acl_not_smtp:
           deny message = Sender rate overlimit - $sender_rate / $sender_rate_period
           ratelimit = 100 / 1h / leaky
           accept

Sorry if question looks like not good, I'm new in server administration.
Thanks.

UPDATE:

Let's simplify. How I can limit messages to send per each virtual host.
Any ideas!

UPDATE:

Any ideas…

What about this:

Add to virtual host:

php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -f owner@domain.com"

And determinatevirtual host from "Return Path"

warn set acl_host  = ${if match{$h_Received:}\
                            {\N Return-path: (Regular expression here) \N}\
                           {$1}\
                            {}\
                  }
acl_not_smtp:
       deny message = Sender rate overlimit - $sender_rate / $sender_rate_period
       ratelimit   = 200 / 1d / leaky / $acl_host
       accept

UPDATET

I add ITK module to Apache, for now each vhost runing from unique user.

Changing configuration to (with authenticated_id):

acl_not_smtp:
               deny message = Sender rate overlimit - $sender_rate / $sender_rate_period
               ratelimit = 100 / 1h / leaky / authenticated_id
               accept

The question is, is it enough for full limits for each user?
And second question how i can add the white list of users that limit will not work in this example.
Thank you.

Best Answer

If you want to do this as is, you are going to need to write a custom exim ACL that extracts the sending domain.

Alternatively you can run php via su_php or use mod_ruid2 to run each vhost as a unique user. Or block direct sendmail injection and require all scripts to send email via authenticated SMTP accounts. Then you can use all of the existing available ACLs.

Related Topic