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

Posted on 2006-04-29
Last Modified: 2010-10-05

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,
Question by:krishneuron
    LVL 3

    Accepted Solution

    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.
    LVL 3

    Expert Comment

    Could you post the solution you used please?

    Author Comment

    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.


    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    I didn’t use eM Client for long when I decided to swap to Outlook 2016. The reason for the switch is that it started asking for payment to continue some of its services after one month.   The problems I faced when I didn’t pay were:   I was not …
    Are you using email marketing software? If not, you're missing out on effortless marketing and the reaching of desired conversion rates through email marketing software.
    This Micro Tutorial demonstrates  how Internet marketers work with competitive analysis data, and a common task in data preparation is creating separate column for domains. You will then extract from a list of URLs.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now