On Sat, Oct 17, 2015 at 06:08:09PM +0200, Boban Davko wrote:
> Recently I have set up mail server using Postfix and Dovecot
> Some of the accounts had to be bcc'ed to more than one account, and
> recipient_bcc_maps doesn't allow that
Actually it does, indirectly. You can Bcc to an alias. Bcc
recipient addresses are subject to virtual(5) alias expansion.
> As an alternative, when email is received the server makes a bcc to
> <account id>@duplicator.localhost When email is received for
> @duplicator.localhost, virtual_alias_maps forwards the email to all accounts
> specified for the current recipient's id (using mysql).
Which appears to be what you're doing.
> This setup works fine up to here with one exception I am trying to fix.
> When the email is forwarded by virtual_alias_maps to some (mailbox type)
> account, it is not bcc'ed further to @duplicator.localhost. Probably this
> happens because the email header of the forwarded email doesn't contain
> the current account as recipient.. Is there any way to rewrite the bcc
> field when forwarding an e-mail using virtual_alias_maps to include the
> current receiving account as recipient? I looked into
> recipient_canonical_maps, but it doesn't seem to allow bcc rewriting..
The recipient_bcc_maps rewriting feature happens *before* virtual
alias expansion.
http://www.postfix.org/ADDRESS_REWRITING_README.html#receiving
Therefore, virtual alias expansion is NOT subject to BCC rewriting.
However, recipient bcc is in most ways just like virtual(5) aliases.
Either way mail is delivered to additional recipients. The only
difference is (to the extent possible) different bounce handling.
So your configuration would be a lot simpler if you switched entirely
from recipient_bcc_maps to virtual_alias_maps, and added all the
required additional recipients that way.
If you want to fancy it up, and emulate the bounce behaviour of
recipient_bcc_maps, you can defer the expansion of bcc recipients,
by not expanding them in virtual alias maps, but instead delivering
them via a custom transport where in addition to expansion of the
recipient, the envelope sender will be replaced. The below is
via a custom "local" transport, but you can also do interesting
things with custom pipe(8) transports, smtp proxies, ...
Warning: not tested!
virtual:
# Indexed file format, but SQL works just as well
us...@example.com us...@example.com, us...@bcc.invalid
transport:
bcc.invalid bcc
master.cf:
bcc unix - n n - - local
-o alias_maps=$bcc_alias_maps
main.cf:
indexed = ${default_database_type}:${config_directory}/
bcc_alias_maps = ${indexed}bcc
bcc:
# Indexed file example, but SQL works just as well
# Key feature, "owner-" aliases replace the envelope
# sender. Assumption, "
example.com" is not a "local"
# domain. Otherwise deliver via SMTP into a separate
# Postfix instance, in which "bcc.invalid" is the only
# local domain in mydestination.
#
owner-user1:
bcc-...@example.com
user1:
bc...@example.com,
bc...@example.com, ...
owner-user2:
bcc-...@example.com
user2:
bc...@example.com,
bc...@example.com, ...
...
--
Viktor.