14

I need Postfix to send outgoing messages (from local PHP) with a certain rate. Say, one message in 120 seconds. Any messages exceeding this rate should be queued (delayed) and delivered later.

Policyd is not what I'm looking for. I don't need limiting overall number of messages sent. I need a pause (120s) between any two messages beeing sent.

Tried this config, but it's not working:

initial_destination_concurrency = 1
default_destination_concurrency_limit = 1
default_destination_rate_delay = 120
default_destination_recipient_limit = 1
default_process_limit = 1

Any suggestions?

Sergey Kovalev
  • 237
  • 1
  • 2
  • 3

7 Answers7

9

You need to set

default_destination_recipient_limit = 2

instead of 1. Because if set to 1 then the limit will only apply to the same recipient, not domain.

Deckard
  • 188
  • 1
  • 7
5

I'd use postfwd. I use it in production for rate limiting servers.

http://postfwd.org/doc.html#examples

2

You can throttle outbound emails:

default_destination_rate_delay = 1s

Postfix will add a delay between each message to the same receiving domain with a delay of 1 second. The default value is 0s.

JonathanDavidArndt
  • 1,414
  • 3
  • 20
  • 29
san5678
  • 21
  • 1
  • According to the manual, http://www.postfix.org/postconf.5.html#default_destination_rate_delay , it should larger than 1s. – Sam Shaw Dec 15 '21 at 06:04
0

When you say that the above config is not working, is it not working to the same destination or to different destinations?

As far as a suggestion, it would be fairly trivial to script an on/off iptables rule to block outgoing connections to port 25. That would be my next suggestion.

Greeblesnort
  • 1,739
  • 8
  • 10
0

Slow down clients sending mail too fast

smtpd_client_connection_rate_limit = 100

smtpd_client_message_rate_limit = 100

smtpd_client_recipient_rate_limit = 200

smtpd_client_new_tls_session_rate_limit = 100

#

check this out

  • Won't work. I need a very low rate. Something like this: blah_blah_rate_limit = 0.01 Seems like commands you suggest are for incoming mail, not outgoing. – Sergey Kovalev Feb 10 '10 at 17:13
0

Maybe playing a bit with qmgr you could obtain some results.

http://www.postfix.org/qmgr.8.html

PiL
  • 1,591
  • 8
  • 6
0

It's really common for people to do this for email going to yahoo. You can look at an example configuration at http://old.nabble.com/Create-Custom-Mail-Queue-td21577217.html#a21577217 , and tweak the numbers as you need.

Bill Weiss
  • 10,782
  • 3
  • 37
  • 65