How to bypass sender_bcc_maps & recipient_bcc_maps for specific users within the same domain


I have a postfix setup for a client domain "" wherein I have configured sender_bcc and recipient_bcc maps in this manner:


where a,b and c are regular users and d is their team leader. However the problem I have is that when d sends mail to either a, b or c, based on the sender_bcc and recipient_bcc rules, d gets a copy of the mail as well -- which is not required.

What I would like to know is that how do I restrict sender/recipient_bcc for a specific user -- i.e. is it possible for me to set a rule where mails between users on the same domain will not be affected by the sender/recipient_bcc rule.

Appreciate your inputs/ideas to implement this.

Best Regards,
Who is Participating?
Would it not be easiest to use a delivery agent filter to eliminate such duplicate mail?

You may be able to achieve this with a content_filter which does the following:

If the sender is and recipient is one or more of , and
then send the mail forward as it is.
If the sender is not and recipient is one or more of , and
then return the mail to Postfix with an additional recipient.

Alternatively, you could use a restriction_class which works like this:

route_differently = check_recipient_access hash:/etc/postfix/recipients

check_sender_access hash:/etc/postfix/senders

/etc/postfix/senders contains      route_differently

/etc/postfix/recipients contains       PREPEND   X-Message-From-d: True       PREPEND   X-Message-From-d: True       PREPEND   X-Message-From-d: True

This will prepend the X-Message-From-d: True header in the message (see access(5) for the details of PREPEND).
Then in the delivery agent, or the MUA, filter on this header and deliver to /dev/null.
Could you post the solution you used please?
krishneuronAuthor Commented:
I was looking at your point of using content filters and since I was already using amavisd-new to filter mail for Virii and Spam, I hit upon another idea.

Therefore I changed the local delivery method to procmail and wrote a procmail recepie to do the filtering for me.

The procmail recipie I used was this ...

* ^From.*<>

:0 Wh: msgid.lock
| formail -D 8192 msgid.cache

# Store Information about the latest message
# c then continue
| echo "${DFROM2_}" > LastIn ;\
  echo "${DSUBJ_}" >> LastIn ;\
  echo "${DWC_}" >> LastIn

# Store Variables
FROM2_=`formail -c -I"Reply-To:" -rt -xTo: \
 | tr '\;\|\$\`\\]/' '     ' \
 | expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'`
DFROM2_=`echo /${FROM2_}/ \
 | expand | sed -e 's/[ \<\>\+\?\$] //g'`
SUBJ_=`formail -z -c -xSubject: \
 | expand | tr '\;\|\$\ `\\] /' '    ' \
 | sed -e 's/ */ /g' \
 | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'`
DSUBJ_=`echo /${SUBJ_}/ | expand | sed -e 's/[ \<\>\+\?\$] //g'`
DWC_=/`wc -w`/

# Discard doubles
# W wait for the filter or program to finish
# supress any 'Program Failure' message
* $ ? sed -n 1p LastIn | egrep -is '${DFROM2_}'
* $ ? sed -n 2p LastIn | egrep -is '${DSUBJ_}'
* $ ? sed -n 3p LastIn | egrep -is '${DWC_}'
  { RULE="Discard doubles" }

The idea for the recepie I got after some serious googling ... so credit to these recepies go to the original creators. They are not my own.

Trust this was of use to you. Thanks for putting my thoughts in this direction.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.