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 "email@example.com" then logwrite "$tod_log Mail to: $h_to from: $sender_address subject: $h_subject bcc'ed to firstname.lastname@example.org" unseen deliver email@example.com endif
So, mail sent from someone matching @test.com to firstname.lastname@example.org will be bcc’ed to email@example.com. Changing firstname.lastname@example.org to just @example.org would obviously catch everything going to the example.org domain through the server.