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 have aliases set up in postfix, such as the following:

all@mydomain.com:    foo@mydomain.com, bar@mydomain.com ...

When an email is sent to all@mydomain.com, and any of the recipients in that alias is cc:ed which is quite common (ie: "Reply all"), the e-mail is delivered in duplicates. For instance, if an e-mail is sent to all@mydomain.com and foo@mydomain.com is cc:ed, it'll get delivered twice. According to the Postfix FAQ, this is by design as Postfix sends e-mail in parallel without expanding the groups, which makes it faster than sendmail. Now that's all fine and dandy, but is it possible to configure Postfix to actually remove duplicate recipients before sending the e-mail?

I've found a lot of posts from people all over the net that has the same problem, but I have yet to find an answer. If this is not possible to do in Postfix, is it possible to do it somewhere on the way? I've tried educating my users, but it's rather futile I'm afraid...

I'm running postfix on Mac OS X Server 10.6, amavis is set as content_filter and dovecot is set as mailbox_command. I've tried setting up procmail as a content_filter for smtp delivery (as per the suggestion below), but I can't seem to get it right. For various reasons, I can't replace the standard OS X configuration, meaning postfix, amavis and dovecot stay put. I can however add to it if I wish.

share|improve this question
    
I think it's really just not possible... –  Antoine Benkemoun Feb 15 '10 at 12:40
    
I'm truly starting to believe that you are right Antoine. –  macke Feb 24 '10 at 10:07
    
Well that was a waste of a bounty... –  macke Feb 25 '10 at 15:26
add comment

3 Answers

Postfix has no idea about duplicate emails due to the way it's structured. It is possible to do what you're suggesting by using procmail as your delivery agent.

Essentially, each message coming from a client should be delivered with a unique Message-Id. In the case that it's delivered to multiple people, the Message-Id should be the same, so we save any Message-Id headers we've seen and discard and future ones that match that list.

From http://novosial.org/procmail/

:0 Wh: msgid.lock
| formail -D 8192 ~/.procmail/msgid.cache
share|improve this answer
    
If I understand the problem correctly, it isn't possible to solve in Postfix because Postfix sends the e-mails in parallel, ie it sends to foo@mydomain.com at the same time as it expands all@mydomain.com and then again sends to foo@mydomain.com. Wouldn't the Procmail solution then possibly introduce a race condition where another unrelated e-mail (with a different message id) is sent in between the two e-mails in question and thus overwriting the cache making it so that duplicate e-mails are delivered anyhow? –  macke Feb 15 '10 at 16:14
    
I'm trying to get your suggestion to work, but I'm not really sure how to combine this with dovecot delivery, which is used by OS X 10.5+ by default. –  macke Feb 15 '10 at 22:46
    
If you're using dovecot as a delivery agent, you can use procmail as a content_filter which will allow you to perform the same task on a global level –  Philip Reynolds Feb 16 '10 at 9:23
    
I have to confess that I probably am in way over my head here. I've been staring myself blind on the configuration parameters page for postfix and googling till my fingers bleed but I can't seem to figure out how to configure this. Any resources you might know of or nudges in the right direction would really be appreciated! –  macke Feb 16 '10 at 18:14
    
I think I sort of understand how it works now, but there's already a content_filter set to amavis. This seems to be some sort of anti virus checker. I've read that it's possible to chain content_filters, but it seems rather unintuitive and the documentation is less than stellar. It's really quite ridiculous how difficult it is to just weed out duplicate e-mails. Design desicions regardless, this seems to me like it should be in there out of the box or at least not require these monstruos hacks. –  macke Feb 16 '10 at 21:25
add comment

This is from some old postfix faq:

Postfix sends duplicate mail Some people will complain that Postfix sends duplicate messages. This happens whenever one message is mailed to multiple addresses that reach the same user. Examples of such scenarios are:

  • One message is sent to the user, and to an alias that lists the user. The user receives one copy of the mail directly, and one copy via the alias.

    • One message is sent to multiple aliases that list the user. The user receives one copy of the mail via each alias.

Some people will even argue that this is the "right" behavior. It is probably more a matter of expectation and of what one is used to.

This can be "fixed" only by making Postfix slower. In the above examples, Postfix would first have to completely expand all distribution lists before starting any delivery. By design, Postfix delivers mail to different destinations in parallel, and local delivery is no exception. This is why Postfix can be faster than sendmail.

So by design you are seeing that behavior. Perhaps if you find a content filter that can strip duplicate message IDs, you can eliminate this after the delivery event.

Sendmail does not have this problem because it expands everything first and strips out duplicates.

share|improve this answer
    
Yes, I read that, perhaps I should have updated my question. By design or not, it's still an issue. I understand why it's behaving the way it does and I understand that trying to find a solution in Postfix is futile. However, I've tried coming up with some content filter solution using Procmail and I just can't seem to get it right. It's highly likely that I'm not understanding content filters or procmail correctly, or both. In either case I still would like to fix this. Unfortunately, the setup as it is cannot be modified, only added to. I can't use sendmail instead of postfix, unfortunately. –  macke Feb 19 '10 at 1:03
    
I updated the question with some more information but honestly, the link to the FAQ was in there to start with. I do appreciate any helpful suggestions though! –  macke Feb 19 '10 at 1:09
    
Did not realize that was a link to the same content. Working in IT security, you become rather paranoid about clicking random links. Can you confirm that the duplicate messages have the same message IDs? –  jeffatrackaid Feb 19 '10 at 1:21
    
Been a long day so I need to review your original post but what about this: postfix.org/postconf.5.html#duplicate_filter_limit –  jeffatrackaid Feb 19 '10 at 1:28
    
I can indeed confirm that the duplicate messages have the same message IDs. Setting the duplicate_filter_limit does nothing to help unfortunately. –  macke Feb 19 '10 at 12:52
add comment

The oficial solution is here.. http://osdir.com/ml/mail.postfix.devel/2007-05/msg00010.html

duplicate_filter_limit (10000) The maximal number of addresses remembered by the recipient duplicate filters for aliases(5) or virtual(5) alias expansion, or for showq(8) queue displays (with earlier Postfix releases the default limit was 1000).

duplicate_filter_style (strict) The duplicate recipient filter policy: strict or pragmatic.

share|improve this answer
    
This doesn't seem to do anything... –  GruffTech Jan 30 '12 at 23:06
add comment

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.