Postfix limit total sent per hour

19,705

Solution 1

You can configure Postfix to divert all messages to the hold queue, and an external script (which you'll need to write) can monitor this queue and release messages at the desired rate.

Solution 2

Postfix does not have that feature by default, you will have to use external program policyd to enforce that rule. I believe you will find the knowledge you seek in this link: http://ngocquyetlinux.blogspot.com/2013/05/limit-mail-with-policyd.html

Share:
19,705

Related videos on Youtube

Miloš Đakonović
Author by

Miloš Đakonović

Updated on September 18, 2022

Comments

  • Miloš Đakonović
    Miloš Đakonović almost 2 years

    I'm not after services that could provide me with fancy fine-grained control like policyd, I don't need per user/domain control, I only want to:

    limit maximim number of emails that could be sent trough Postfix mail system per hour, preferably but not necessary excluding domains that Postfix mail system itself handles.

    Let's say I want to set limit of 200 messages per hour. Desired behavior is that 201 message holds until one hour period is over in order to be delivered.

    I would be really amazed if solution to this could respect my previously set per-domain rate limits:

    smtp_destination_concurrency_limit = 1
    smtp_destination_rate_delay = 3s
    smtp_extra_recipient_limit = 2
    

    EDIT: here are some configuration options that might be related to what I'm looking for:

    anvil_rate_time_unit = 120s
    smtpd_client_recipient_rate_limit = 4
    smtpd_client_message_rate_limit = 4
    smtpd_client_connection_count_limit = 1
    smtpd_client_connection_rate_limit = 1
    

    This configuration should limit 4 emails per 2 minutes, thus 120 per hour - but I'm not sure if it works.

    • André Borie
      André Borie about 8 years
      A very crude approach would be to rate limit outgoing connections using IPtables.
    • Miloš Đakonović
      Miloš Đakonović about 8 years
      @AndréBorie Would that be feasible?
    • André Borie
      André Borie about 8 years
      Feasible, yes. But also awful and definitely not the right tool for the job.
    • Jacob Evans
      Jacob Evans about 8 years
      If you used iptables you would need to disable connection cache
    • DictatorBob
      DictatorBob almost 8 years
      Isn't this a duplicate of: serverfault.com/questions/110919/…? I also don't understand why you think that smtp_destination_rate_delay won't do what you need....
    • Miloš Đakonović
      Miloš Đakonović almost 8 years
      @DictatorBob smtp_destination_rate_delay applies per domain, AFAIK.
  • busythomas
    busythomas almost 4 years
    Sorry but this answer was not helpful.
  • busythomas
    busythomas almost 4 years
    Thank you, I tried policyd and unfortunately it was causing high server load. I do not recommend Policyd.