Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to bounce messages that are going to through my Postfix server that have too many unique domains in the To and CC fields. Is there a simple way of doing this with Postfix? (I am new to Postfix, normally a sendmail user).

Added/edited

To/CC: User1@exampleA.com, User2@exampleB.com, User3@exampleC.com, User4@exampleD.com, User5@exampleE.com, User6@exampleF.com, User7@exampleG.com, User8@exampleH.com, User9@exampleI.com, User10@exampleJ.com, User11@exampleK.com

Should bounce to the user.

To/CC: User1@exampleA.com, User2@exampleA.com, User3@exampleA.com, User4@exampleA.com, User5@exampleA.com, User6@exampleA.com, User7@exampleA.com, User8@exampleA.com, User9@exampleA.com, User10@exampleA.com, User11@exampleA.com, User12@exampleA.com

Should go through.

share|improve this question
    
Please give me more information. What are unique domains? Do subdomains count? What if you have two domains with equal count? Do To: and Cc: make a difference? ... ... ... And by the way what is "too many"? Two? –  mailq Aug 29 '11 at 18:59
    
Sub domains would count. so Joe@foo.bar.com and Joe@bar.com would be 2. Right now that magic number is being discussed. I think it is going to be something like 10. But at the same time if someone sends to 50 people at the same domain I need it to go through. –  Joe Coder Aug 29 '11 at 20:03
    
That makes it more vague than clearer. When is there the 10 address limit and when the 50 address limit? –  mailq Aug 29 '11 at 20:57
    
sorry 50 was just an example, that the 10 unique domain limit cannot limit the number in the To: and CC: if they are the same domain. Not sure how else to explain it. From my understanding smtpd_client_recipient_rate_limit sets a limit on how many total addresses can be in the to and cc. –  Joe Coder Aug 31 '11 at 0:24

3 Answers 3

up vote 0 down vote accepted

There is no simple way to do that. In Postfix there is no mechanism that you can do statistics on recipients before accepting or denying them. It must be kept in mind that Postfix is a mail server and has only limited possibilities of content inspection.

To do this you can add before-queue milters (write your own) or look into the possibilities of a policy service (write your own). The easiest way of both is the policy service which can be achieved with an easy Perl script or whatever you prefer. The whole documentation with an example Perl implementation can be found at the Postfix documentation. There are other implementations using the same interface but don't do what you want in your special case. One is policyd-weight.

If you are familiar with writing SpamAssassin rules you could try to add one and use amavisd-new as a before-queue filter.

But as I said there is no built-in solution for your case. The other answers to your question are only global restrictions that don't help here.

share|improve this answer

Use smtpd_recipient_overshoot_limit (and smtpd_recipient_limit)

   smtpd_recipient_overshoot_limit (1000)
          The number of recipients that a remote SMTP  client
          can  send  in  excess  of  the limit specified with
          $smtpd_recipient_limit,  before  the  Postfix  SMTP
          server  increments  the per-session error count for
          each excess recipient.
share|improve this answer
    
This does not take into account that there should be a per domain limit and not an overall limit. –  mailq Aug 29 '11 at 20:59

Check:

smtpd_client_recipient_rate_limit (default: 0)

*The maximal number of recipient addresses that any client is allowed to send to this service per time unit, regardless of whether or not Postfix actually accepts those recipients. The time unit is specified with the anvil_rate_time_unit configuration parameter. By default, a client can send as many recipient addresses per time unit as Postfix can accept.*

To disable this feature, specify a limit of 0.

smtpd_client_message_rate_limit (default: 0)

*The maximal number of message delivery requests that any client is allowed to make to this service per time unit, regardless of whether or not Postfix actually accepts those messages. The time unit is specified with the anvil_rate_time_unit configuration parameter. By default, a client can send as many message delivery requests per time unit as Postfix can accept. To disable this feature, specify a limit of 0.*

As postconf man page suggests.

share|improve this answer
    
This is an overall limit and not a "per domain" limit. –  mailq Aug 29 '11 at 20:59
    
Yes I know what it is; it's mere suggestion for OP to consider. –  Hrvoje Špoljar Aug 29 '11 at 22:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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