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

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

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


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,
Question by:krishneuron
  • 2

Accepted Solution

DVB earned 1500 total points
ID: 16583486
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.

Expert Comment

ID: 16733092
Could you post the solution you used please?

Author Comment

ID: 16735476
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.*<recipient@domain.com>

: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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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.
Mailbox Corruption is a nightmare every Exchange DBA wishes he never has. Recovering from it can be super-hectic if not entirely futile. And though techniques like the New-MailboxRepairRequest cmdlet have been designed to help with fixing minor corr…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

862 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