Home > Uncategorized > Throttling outgoing emails to certain domains with Postfix

Throttling outgoing emails to certain domains with Postfix

I’ve been busy setting up a PHPlist server for my employer. All tests went ok, but as soon as we sent our first newsletter Yahoo! blocked the server. After looking around for a solution people suggested we sign all outgoing emails with DomainKeys and not hammer Yahoo’s servers with consecutive connection.

Using DomainKeys was a simple setup with DKIMproxy, as for throttling, you all know Postfix is one high performance MTA, so that would be hard to do. PHPlist has a throttling feature but I didn’t want to use that because it would slow emails going to all domains and it took about half a day to send messages to about 6,000 users. That is unacceptable.

Update: Yahoo and other providers throttle inbound connections in an attempt to reduce spam. If you’re a big operator, talk to them about whitelisting. If not, just wait for the retry, your mail eventually goes through. For bulk mail issues this contact is helpful: <mail-abuse-bulk@cc.yahoo-inc.com>

After some more digging around I found that Postfix 2.5 introduced the perfect solution, here you go:

First, add the following lines to your master.cf


domain1      unix  -       -       n       -       -       smtp
        -o smtp_fallback_relay=
domain2      unix  -       -       n       -       -       smtp
        -o smtp_fallback_relay=
domain3      unix  -       -       n       -       -       smtp
        -o smtp_fallback_relay=

 

Now, to use those transports add these lines to your transport_maps file


domain1.tld    domain1:
domain2.tld    domain2:
domain3.tld    domain3:

 

Finally, set the destination_rate_delay for those transports in main.cf


domain1_destination_rate_delay = 10s
domain2_destination_rate_delay = 20s
domain3_destination_rate_delay = 30s

 

This will effectively send all outgoing messages at full speed, except for messages going to domain1.tld, domain2.tld, and domain3.tld; Postfix will wait 10/20/30 seconds after sending each message to domain1.tld/domain2.tld/domain3.tld.

Categories: Uncategorized Tags: ,
  1. June 25th, 2010 at 11:46 | #1

    Nice !!!!

    it s exactly that i research .

    Thank you .

    Franck

  2. Fabinou
    July 9th, 2010 at 16:05 | #2

    Thanks a lot for this great tutorial ! But i have a problem, it seems that my postfix (2.7.0) doesnt care about my params :

    main.cf
    transport_maps = hash:/etc/postfix/transport
    slow_destination_rate_delay = 2s

    transport :
    free.fr slow:
    aliceadsl.fr slow:
    libertysurf.fr slow:

    master.cf
    slow unix – – – – – smtp

    That’s my configuration, but here what i have in my log

    Jul 9 15:55:10 ASF1 postfix/error[10229]: B6EF5104: to=, relay=none, delay=2367, delays=2367/0.12/0/0, dsn=4.0.0, status=deferred (delivery temporarily suspended: host mx2.free.fr[212.27.42.58] refused to talk to me: 421 Too many spams from your IP (9yyy), please visit http://postmaster.free.fr/)
    Jul 9 15:55:10 ASF1 postfix/error[10230]: B7B7911C: to=, relay=none, delay=2352, delays=2352/0.12/0/0, dsn=4.0.0, status=deferred (delivery temporarily suspended: host mx2.free.fr[212.27.42.58] refused to talk to me: 421 Too many spams from your IP (95.143.65.145), please visit http://postmaster.free.fr/)
    Jul 9 15:55:10 ASF1 postfix/error[10229]: F25B110A: to=, relay=none, delay=2363, delays=2363/0.12/0/0, dsn=4.0.0, status=deferred (delivery temporarily suspended: host mx2.free.fr[212.27.42.58] refused to talk to me: 421 Too many spams from your IP (yyyy), please visit http://postmaster.free.fr/)
    Jul 9 15:55:10 ASF1 postfix/error[10228]: 75D6C119: to=, relay=none, delay=2356, delays=2356/0.12/0/0, dsn=4.0.0, status=deferred (delivery temporarily suspended: host mx2.free.fr[212.27.42.58] refused to talk to me: 421 Too many spams from your IP (yyyy), please visit http://postmaster.free.fr/)

    As u can see, there’s no delay beetween mails. What i am doing wrong ?

    • mohshami
      March 22nd, 2011 at 22:08 | #3

      Sorry for the late reply.

      Have you been able to fix this?

  3. September 29th, 2010 at 05:16 | #4

    You had success with this? I have implemented in Postfix2.7 and sent two emails at the same time both delivered immediately. Any difficulties you had in 2.5 other than what was stated above?

    • mohshami
      March 22nd, 2011 at 22:04 | #5

      Sadly I haven’t tried it on Postfix 2.7, but it should work without issues.

  4. October 8th, 2010 at 16:14 | #6

    Thanks Shami for an Excellent article.
    This helped me a lot !! :)

  5. artware
    December 8th, 2010 at 12:06 | #7

    Please ,patience….correct me that I make something wrong.
    I have problems only with yahoo server, and I make settings like that:

    master.cf:
    yahoo.com unix – – n – – smtp
    -o smtp_fallback_relay=

    /etc/postfix/transport:
    yahoo.com yahoo:

    main.cf:
    yahoo.com_destination_rate_delay = 10s
    transport_maps = hash:/etc/postfix/transport

    Is everything OK, I miss something?
    THX

  6. mohshami
    March 22nd, 2011 at 22:12 | #8

    Sadly I haven’t used this in a while, I’ll try to check it during the weekend if I find the time.

  7. Mohammad Al-Shami
    March 30th, 2011 at 23:02 | #9

    Update, I tried it with Postfix 2.8 and it works properly

  1. No trackbacks yet.