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

Hi,

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

sender_bcc

a@domain.com  d@domain.com
b@domain.com  d@domain.com
c@domain.com  d@domain.com

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,
Krish
krishneuronAsked:
Who is Participating?
 
DVBCommented:
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 d@example.com and recipient is one or more of a@example.com ,b@example.com and c@example.com
then send the mail forward as it is.
If the sender is not d@example.com and recipient is one or more of a@example.com ,b@example.com and c@example.com
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
d@example.com      route_differently

/etc/postfix/recipients contains
a@example.com       PREPEND   X-Message-From-d: True
b@example.com       PREPEND   X-Message-From-d: True
c@example.com       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.
0
 
DVBCommented:
Could you post the solution you used please?
0
 
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 ...

:0
* ^From.*<recipient@domain.com>
/dev/null

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

# Store Information about the latest message
# c then continue
:0Wc
| 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
:0W
* $ ? sed -n 1p LastIn | egrep -is '${DFROM2_}'
* $ ? sed -n 2p LastIn | egrep -is '${DSUBJ_}'
* $ ? sed -n 3p LastIn | egrep -is '${DWC_}'
{
  :0
  { RULE="Discard doubles" }
  :0
  /dev/null
}

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.

Cheers,
Krish
0
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.