If you’re unfortunate enough to be using Exim, and you need to configure the server to selectively bcc some emails (e.g. emails going to a specific recipient need bcc’ing to another address for archiving/compliance purposes) then the following may be useful :
1. Edit /etc/exim4/exim4.conf and add near the top the following :
system_filter = /etc/exim4/mail.filter system_filter_user = Debian-exim
and restart Exim.
2. Edit /etc/exim4/mail.filter as per the documentation creating something a bit like :
# Exim filter
logfile /tmp/mail.log
logwrite "$tod_log $h_to $h_from $h_subject "
if $header_x-loop-systemfilter contains 'ok'
then
logwrite "Mail loop?"
finish
endif
headers add "X-Loop-SystemFilter: ok"
if $sender_address contains "@test.com" and $h_to contains "destination@example.org"
then
logwrite "$tod_log Mail to: $h_to from: $sender_address subject: $h_subject bcc'ed to bcc_address@example.org"
unseen deliver bcc_address@example.org
endif
So, mail sent from someone matching @test.com to destination@example.org will be bcc’ed to bcc_address@example.org. Changing destination@example.org to just @example.org would obviously catch everything going to the example.org domain through the server.